﻿// UnitTest.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#ifdef WIN32
#include <windows.h>
#include <assert.h>
#endif
#include <conio.h>
#include "Engine.h"
#include "GBRetInfo.h"
#ifndef ARRAY_DIM
#define ARRAY_DIM(a)	(sizeof(a) / sizeof((a)[0]))
#endif

GBINT g_APICount = 0;
/*!
* \brief 反查返回值信息
* \param const GBACHAR * pStrInfo
*/
#define LookUpReturnValueInfomation(val, pStrInfo, size)  GetV5RetInfoToValue(val, pStrInfo, size, NULL)
/*!
* \brief 通过返回值类型和返回值反查返回值信息
* \param const GBACHAR * pStrInfo
*/
#define LookUpReturnValueInfomationToType(valType, val, pStrInfo)	GetEngineRetInfo(valType, val, pStrInfo, 1);

#define SAMPLECODE_BEGIN(fun)
#define SAMPLECODE_END(fun)
#define PRINTFUNCTIONINFO_BEGIN(fun)   \
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("\r\n"));   \
	PT_PrintModuleLogInfo(e_GBLOG_UNITTEST, ("------%s API单元测试开始------\r\n", #fun))
#define PRINTFUNCTIONINFO_END(fun)   \
	PT_PrintModuleLogInfo(e_GBLOG_UNITTEST, ("------%s AP%I单元测试结束------\r\n", #fun));
/*! 打印反差信息 */
#define PRINTLOOKUPINFOMATION(val){  \
	GBACHAR szStrInfo[128] = {0};  \
	LookUpReturnValueInfomation(retVal, szStrInfo, 128);  \
	if (NULL != szStrInfo)  \
{  \
	PT_PrintModuleLogInfo(e_GBLOG_UNITTEST, ("return retVal = %d, 反查结果：%s \r\n", retVal, szStrInfo));  \
}  \
	else  \
{  \
	PT_PrintModuleLogInfo(e_GBLOG_UNITTEST, ("return retVal = %d, 反查结果失败 \r\n", retVal));  \
}  \
}

/*! 打印反差信息 */
#define PRINTLOOKUPINFOMATIONEX(valType, val){  \
	GBPWCHAR pStrInfo = NULL;  \
	LookUpReturnValueInfomationToType(valType, retVal, &pStrInfo);  \
	if (NULL != pStrInfo)  \
{  \
	PT_PrintModuleLogInfoW(e_GBLOG_UNITTEST, (L"return retVal = %d, 反查结果：%s \r\n", retVal, pStrInfo));  \
}  \
	else  \
{  \
	PT_PrintModuleLogInfoW(e_GBLOG_UNITTEST, (L"return retVal = %d, 反查结果失败 \r\n", retVal));  \
}  \
}

#define SET_INPUT_MODE(pGBIS, nLang, nSubLang, nInputMode) \
	GBSetCurLanguage(pGBIS, nLang, nSubLang); \
	GBSetInputMode(pGBIS, nInputMode); \
	switch(nLang) \
{ \
	case GBL_Chinese: \
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Set lang: %s\r\n", "GBL_Chinese")); \
	break; \
	case GBL_English: \
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Set lang: %s\r\n", "GBL_English")); \
	break; \
	default: \
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Set lang: %d\r\n", nLang)); \
	break; \
} \
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Set input mode : %s\r\n", GetInputModeStr(nInputMode))); 

#define SET_INPUT_STRING(pGBIS, c_inputStr) \
	wcscpy(pGBIS->inputString, c_inputStr); \
	pGBIS->inputStringLen = (GBU8)wcslen(c_inputStr); \
	pGBIS->flags |= GBIS_INPUT_STRING_UPDATED; \
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"Set input string = %s \r\n", c_inputStr));

#define PRINT_CANDS(pGBIS) \
{ \
	int i = 0; \
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"cand list:\r\n")); \
	for (i = 0; i < pGBIS->outputInfo.nCandNum; i++) \
	{ \
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"[%d] %s  ", i, pGBIS->outputInfo.pCandidates[i])); \
	} \
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"\r\n")); \
}
#define PRINT_SYLLABLE(pGBIS) \
{ \
	int i = 0;  \
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("syllable list : \r\n")); \
	for (i = 0; i < pGBIS->pAuxInfo->nSyllableNum; i++) \
	{ \
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"[%d] %s  ", i, pGBIS->pAuxInfo->pSyllables[i])); \
	} \
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("\r\n")); \
}
// void WINAPI onTimeFunc(UINT wTimerID, UINT msg,DWORD dwUser,DWORD dwl,DWORD dw2)
// {
// 	pGBInputStruct pGBIS = GetEngineInputStruct();
// 	GBMMIHandleKeyEvent(pGBIS, GBKEY_OK, 0);
// }
GBU32 onKillTimer(GBLPVOID pOEMPrivateData, GBU32 nTimerID)
{
	//return timeKillEvent(nTimerID);
	return 0;
}

GBU32 onSetTimer(GBLPVOID pOEMPrivateData, GBINT nTimerID)
{	
	//return timeSetEvent(1000, 1, (LPTIMECALLBACK)onTimeFunc, 1, TIME_ONESHOT);
	return 0;
}
int LogRecorder(GBLPVOID pOEMData, const char * format, unsigned long p1, unsigned long p2, unsigned long p3, unsigned long p4)
{
	//printf("引擎正在打印log\r\n");
	fprintf(stderr, format, p1, p2, p3, p4);
	return 0;
}
static void GBUDBUpdateFun(GBI32 nUDBID, GBLPVOID pData, GBU32 len, GBLPVOID pOEMUpdateParam)
{
	printf("验证GBUDBSetUpdateParam\n");
}
static void GBUpContentUpdateFun(GBI32 nUDBID, GBLPVOID pData, GBU32 len, GBLPVOID pOEMUpdateParam)
{
	printf("验证GBChnUDBSetUpdateParam\n");
}
//////////////////////////////////////////////////////////////////////////
//#Initialization 引擎初始化
SAMPLECODE_BEGIN(GBInputStructGetPrivateBufferUsedSize)
// 获取引擎需要的空间
static void UT_GBInputStructGetPrivateBufferUsedSize(pGBInputStruct pGBIS)
{
	GBINT size;
	PRINTFUNCTIONINFO_BEGIN(GBInputStructGetPrivateBufferUsedSize);
	size = GBInputStructGetPrivateBufferUsedSize();
	PT_PrintModuleLogInfo(e_GBLOG_UNITTEST, ("GBIM_GetEngineSize = %d \r\n", size));
	PRINTFUNCTIONINFO_END(GBInputStructGetPrivateBufferUsedSize);
}
SAMPLECODE_END(GBInputStructGetPrivateBufferUsedSize)


SAMPLECODE_BEGIN(GBInitialize)
static void UT_GBInitialize(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBU16 * pLDBCount = GetEngineLDBDataCount();
	GBLDB * pLDBInfo = GetEngineLDBDataInfo();
	PRINTFUNCTIONINFO_BEGIN(GBInitialize);
	retVal = GBInitialize(pGBIS, pLDBInfo, *pLDBCount);
	PRINTLOOKUPINFOMATION(retVal);
	if (retVal != GBOK)
	{
		retVal = GBTerminate(pGBIS);
		PT_PrintModuleLogInfo(e_GBLOG_UNITTEST, ("GBTerminate : ret = %d \r\n", retVal));
		retVal = GBInitialize(pGBIS, pLDBInfo, *pLDBCount);
		PRINTLOOKUPINFOMATION(retVal);
	}
	PRINTFUNCTIONINFO_END(GBInitialize);
}
SAMPLECODE_END(GBInitialize)

SAMPLECODE_BEGIN(GBIsInited)
// 检查引擎是否启动成功
static GBBOOL UT_GBIsInited(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	PRINTFUNCTIONINFO_BEGIN(GBIsInited);
	retVal = GBIsInited(pGBIS);
	PRINTLOOKUPINFOMATION(retVal);
	PRINTFUNCTIONINFO_END(GBIsInited);
	if(GBOK == retVal)
	{
		return GBTrue;
	}
	else
	{
		return GBFalse;
	}
}
SAMPLECODE_END(GBIsInited)


SAMPLECODE_BEGIN(GBTerminate)
// 关闭国笔引擎
static void UT_GBTerminate(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	PRINTFUNCTIONINFO_BEGIN(GBTerminate);

	retVal = GBTerminate(pGBIS);
	PRINTLOOKUPINFOMATION(retVal);

	PRINTFUNCTIONINFO_END(GBTerminate);
}
SAMPLECODE_END(GBTerminate)


SAMPLECODE_BEGIN(GBReset)
static void UT_GBReset(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	PRINTFUNCTIONINFO_BEGIN(GBReset);

	retVal = GBReset(pGBIS);
	PRINTLOOKUPINFOMATION(retVal);

	PRINTFUNCTIONINFO_END(GBReset);
}
SAMPLECODE_END(GBReset)


SAMPLECODE_BEGIN(GBSetCurLanguage)
static void UT_GBSetCurLanguage(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	PRINTFUNCTIONINFO_BEGIN(GBSetCurLanguage);

	retVal = GBSetCurLanguage(pGBIS, GBL_Chinese, GBL_Sub_Not_Spec);
	PRINTLOOKUPINFOMATION(retVal);

	PRINTFUNCTIONINFO_END(GBSetCurLanguage);
}
SAMPLECODE_END(GBSetCurLanguage)


SAMPLECODE_BEGIN(GBSetInputMode)
static void UT_GBSetInputMode(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	GBPACHAR pStr = NULL;
	GBINT index;

	PRINTFUNCTIONINFO_BEGIN(GBSetInputMode);

	PT_PrintModuleLogInfo(e_GBLOG_UNITTEST, ("SetCurLang = GBL_Chinese \r\n"));
	//首先测试中文数据
	GBSetCurLanguage(pGBIS, GBL_Chinese, GBL_Sub_Not_Spec);
	PRINTLOOKUPINFOMATION(retVal);
	for (index = GBIM_Pinyin; index < GBIM_Max; index++)
	{
		retVal = GBSetInputMode(pGBIS, index);
		pStr = GetInputModeStr(index);
		PT_PrintModuleLogInfo(e_GBLOG_UNITTEST, ("GBL_Chinese SetInputMode = %s \r\n", pStr));
		PRINTLOOKUPINFOMATION(retVal);	
	}
	//再次测试英文数据
	GBSetCurLanguage(pGBIS, GBL_English, GBL_Sub_Not_Spec);
	PRINTLOOKUPINFOMATION(retVal);
	for (index = GBIM_Pinyin; index < GBIM_Max; index++)
	{
		retVal = GBSetInputMode(pGBIS, index);
		pStr = GetInputModeStr(index);
		PT_PrintModuleLogInfo(e_GBLOG_UNITTEST, ("GBL_English SetInputMode = %s \r\n", pStr));
		PRINTLOOKUPINFOMATION(retVal);	
	}

	PRINTFUNCTIONINFO_END(GBSetInputMode);
}
SAMPLECODE_END(GBSetInputMode)


SAMPLECODE_BEGIN(GBMMISetInputMode)
static void UT_GBMMISetInputMode(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	PRINTFUNCTIONINFO_BEGIN(GBMMISetInputMode);
	PT_PrintModuleLogInfo(e_GBLOG_UNITTEST, ("GBSetCurLanguage : %s \r\n", "GBL_Chinese"));
	GBSetCurLanguage(pGBIS, GBL_Chinese, 0);
	PT_PrintModuleLogInfo(e_GBLOG_UNITTEST, ("GBMMISetInputMode : %s \r\n", "GBIM_Pinyin"));
	retVal = GBMMISetInputMode(pGBIS, GBIM_Pinyin);
	PRINTLOOKUPINFOMATION(retVal);
	PRINTFUNCTIONINFO_END(GBMMISetInputMode);
}
SAMPLECODE_END(GBMMISetInputMode)

//#Configuration	API引擎配置

SAMPLECODE_BEGIN(GBSetCandidateMaxCount)
static void UT_GBSetCandidateMaxCount(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	GBINT candCount = 0;
	const GBINT MAX_CAND_COUNT = 100;

	PRINTFUNCTIONINFO_BEGIN(GBSetCandidateMaxCount);
	
	candCount = -1;
	do
	{
		PT_PrintModuleLogInfo(e_GBLOG_UNITTEST, ("设置候选最大行数 : %d\n", candCount));
		retVal= GBSetCandidateMaxCount(pGBIS, candCount);
		PRINTLOOKUPINFOMATION(retVal);	
		if (-1 == candCount)
		{
			candCount = 0;
		}
		else
		{
			candCount += 5;
		}
	}while(candCount < MAX_CAND_COUNT);

	PRINTFUNCTIONINFO_END(GBSetCandidateMaxCount);
}
SAMPLECODE_END(GBSetCandidateMaxCount)


SAMPLECODE_BEGIN(GBGetCandidateMaxCount)
static void UT_GBGetCandidateMaxCount(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	GBINT maxCount = 0;
	PRINTFUNCTIONINFO_BEGIN(GBGetCandidateMaxCount);
	retVal = GBGetCandidateMaxCount(pGBIS, &maxCount);
	PT_PrintModuleLogInfo(e_GBLOG_UNITTEST, ("当前候选最大个数为 : %d\n", maxCount));
	PRINTLOOKUPINFOMATION(retVal);
	PRINTFUNCTIONINFO_END(GBGetCandidateMaxCount);
}
SAMPLECODE_END(GBGetCandidateMaxCount)


SAMPLECODE_BEGIN(GBSetLanguageSymbols)
static void UT_GBSetLanguageSymbols(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	// 由OEM指定任意unicode字符集，实际使用时必须为全局变量
	static GBWCHAR *pOEMSymobls = L"#^*)5rU+*";	
	PRINTFUNCTIONINFO_BEGIN(GBSetLanguageSymbols);

	// 设置语言及输入模式
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	// 指定“*”键为标点符号键
	GBMMIRegisterInterpunctionKey(pGBIS, GBKEY_AMB_SPECIAL_A, NULL, 10);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("注册标点 : %s\n", "#^*)5rU+*"));
	retVal = GBSetLanguageSymbols(pGBIS, pOEMSymobls);
	PRINTLOOKUPINFOMATION(retVal);	
	if (GBOK == retVal)
	{
		GBINT idx = 0;
		GBACHAR symbols[128] = {0};
		GBOutputInfo * pOutputInfo = &pGBIS->outputInfo;
		GBMMIHandleKeyEvent(pGBIS, GBKEY_AMB_SPECIAL_A, 0);
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("pOutputInfo->nCandNum = %d \r\n", pOutputInfo->nCandNum));
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("OEM symbols list: \r\n"));
		for(idx = 0; idx < pOutputInfo->nCandNum; idx++)
		{
			memset(symbols, 0, sizeof(symbols));
			_wcstombs(symbols, pOutputInfo->pCandidates[idx], sizeof(symbols));
			PT_PrintLogInfo(e_GBLOG_UNITTEST, ("%s\t", symbols));
		}
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("\r\n"));
	}

	PRINTFUNCTIONINFO_END(GBSetLanguageSymbols);
}
SAMPLECODE_END(GBSetLanguageSymbols)


SAMPLECODE_BEGIN(GBSetPageOption)
static void UT_GBSetPageOption(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	GBGlobalPageOption pageOption;

	PRINTFUNCTIONINFO_BEGIN(GBSetPageOption);
	// 设置语言及输入模式
	GBSetCurLanguage(pGBIS, GBL_Chinese, 0);
	GBSetInputMode(pGBIS, GBIM_Pinyin);
	// 获取默认分页配置参数
	GBGetPageOption(pGBIS, &pageOption);
	// 设置中文模糊拼音每页返回4个音节
	pageOption.mSyllablePageOption.nMaxCandCountPerPage = 4;
	retVal = GBSetPageOption(pGBIS, &pageOption);

	PRINTLOOKUPINFOMATION(retVal);	

	PRINTFUNCTIONINFO_END(GBSetPageOption);
}
SAMPLECODE_END(GBSetPageOption)


SAMPLECODE_BEGIN(GBGetPageOption)
static void UT_GBGetPageOption(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	GBGlobalPageOption pageOption;
	PRINTFUNCTIONINFO_BEGIN(GBGetPageOption);

	// 获取默认分页配置参数
	retVal = GBGetPageOption(pGBIS, &pageOption);
	PRINTLOOKUPINFOMATION(retVal);	
	if(GBOK == retVal)
	{
		// 中文音节分页
		PT_PrintLogInfo(e_GBLOG_UNITTEST,("中文音节分页 nTotalWidthInPixel = %d, nCharWidthInPixel = %d,nSplitWidthInPixel = %d, nMaxCandCountPerPage = %d\n",
										  pageOption.mSyllablePageOption.nTotalWidthInPixel, pageOption.mSyllablePageOption.nCharWidthInPixel, 
										  pageOption.mSyllablePageOption.nSplitWidthInPixel, pageOption.mSyllablePageOption.nMaxCandCountPerPage));
		// 候选字词分页
		PT_PrintLogInfo(e_GBLOG_UNITTEST,("候选字词分页 nTotalWidthInPixel = %d, nCharWidthInPixel = %d, nSplitWidthInPixel = %d, nMaxCandCountPerPage = %d\n",
										  pageOption.mChnCandPageOption.nTotalWidthInPixel, pageOption.mChnCandPageOption.nCharWidthInPixel, 
										  pageOption.mChnCandPageOption.nSplitWidthInPixel, pageOption.mChnCandPageOption.nMaxCandCountPerPage));
		// 外文单词分页
		PT_PrintLogInfo(e_GBLOG_UNITTEST,("外文单词分页 nTotalWidthInPixel = %d, nCharWidthInPixel = %d, nSplitWidthInPixel = %d, nMaxCandCountPerPage = %d\n",
										  pageOption.mPageOption.nTotalWidthInPixel, pageOption.mPageOption.nCharWidthInPixel, 
										  pageOption.mPageOption.nSplitWidthInPixel, pageOption.mPageOption.nMaxCandCountPerPage));
	}

	PRINTFUNCTIONINFO_END(GBGetPageOption);
}
SAMPLECODE_END(GBGetPageOption)


SAMPLECODE_BEGIN(GBSetMaxTotalPages)
static void UT_GBSetMaxTotalPages(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	GBINT pageCount = 0;
	const GBINT MAX_PAGE_COUNT = 32;

	PRINTFUNCTIONINFO_BEGIN(GBSetMaxTotalPages);

	for	(pageCount = 0; pageCount < MAX_PAGE_COUNT; pageCount+=2)
	{
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Set max Toal page : %d\n", pageCount));
		retVal = GBSetMaxTotalPages(pGBIS, pageCount);
		PRINTLOOKUPINFOMATION(retVal);	
	}

	PRINTFUNCTIONINFO_END(GBSetMaxTotalPages);
}
SAMPLECODE_END(GBSetMaxTotalPages)


SAMPLECODE_BEGIN(GBGetMaxTotalPages)
static void UT_GBGetMaxTotalPages(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	GBINT nMaxPageCount = 0;

	PRINTFUNCTIONINFO_BEGIN(GBGetMaxTotalPages);

	retVal = GBGetMaxTotalPages(pGBIS, &nMaxPageCount);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Get max Toal page : %d\n", nMaxPageCount));
	PRINTLOOKUPINFOMATION(retVal);	

	PRINTFUNCTIONINFO_END(GBGetMaxTotalPages);
}
SAMPLECODE_END(GBGetMaxTotalPages)


SAMPLECODE_BEGIN(GBSetCandidateMaxWordLength)
static void UT_GBSetCandidateMaxWordLength(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	GBINT nCandMaxWordLength = 3;

	PRINTFUNCTIONINFO_BEGIN(GBSetCandidateMaxWordLength);

	// 返回的每个候选，最大长度不超过2
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("set cand max word length : %d\r\n", nCandMaxWordLength));
	//option为2-10的一个数字
	retVal = GBSetCandidateMaxWordLength(pGBIS, nCandMaxWordLength);
	PRINTLOOKUPINFOMATION(retVal);	
	if(GBOK == retVal)
	{
		GBINT idx = 0;
		GBACHAR cand[128] = {0};
		GBOutputInfo * pOutputInfo = &pGBIS->outputInfo;
		//const GBWCHAR c_inputStr[] = {'9', '6', '6', '3', '6', 0};	// 输入“我们”
		const GBWCHAR c_inputStr[] = L"842684269426474264";
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Set input string = %s \r\n", "842684269426474264"));
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("default cand = %s \r\n", "天天向上,天天,甜甜,挑剔,提案,天"));
		

		wcscpy(pGBIS->inputString, c_inputStr);
		pGBIS->inputStringLen = (GBU8)wcslen(c_inputStr);
		pGBIS->flags |= GBIS_INPUT_STRING_UPDATED;
		retVal = GBNextPageCandidate(pGBIS, 0);
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBNextPageCandidate ret : %d \r\n", retVal));
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("pOutputInfo->nCandNum = %d \r\n", pOutputInfo->nCandNum));
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Candidates List： \r\n"));
		for(idx = 0; idx < pOutputInfo->nCandNum; idx++)
		{
			memset(cand, 0, sizeof(cand));
			_wcstombs(cand, pOutputInfo->pCandidates[idx], sizeof(cand));
			PT_PrintLogInfo(e_GBLOG_UNITTEST, ("%s\t", cand));
		}
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("\r\n"));
	}

	PRINTFUNCTIONINFO_END(GBSetCandidateMaxWordLength);
}
SAMPLECODE_END(GBSetCandidateMaxWordLength)


SAMPLECODE_BEGIN(GBSetInputString)
static void UT_GBSetInputString(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	GBLPWCHAR c_inputString = L"96636";
	PRINTFUNCTIONINFO_BEGIN(GBSetInputString);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	retVal = GBSetInputString(pGBIS, c_inputString);
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBSetInputString : %s \r\n", c_inputString));
	PRINTLOOKUPINFOMATION(retVal);
	PRINT_CANDS(pGBIS);
	PRINTFUNCTIONINFO_END(GBSetInputString);
}
SAMPLECODE_END(GBSetInputString)


SAMPLECODE_BEGIN(GBHelperAddInputChar)
static void UT_GBHelperAddInputChar(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	GBLPWCHAR c_inputString = L"2";
	GBWCHAR c_addInputString = L'3';
	PRINTFUNCTIONINFO_BEGIN(GBHelperAddInputChar);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	GBSetInputString(pGBIS, c_inputString);
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBSetInputString : %s \r\n", c_inputString));
	GBGetPagedSyllable(pGBIS, GBPS_FIRST_PAGE);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetPagedSyllable : %s \r\n", "GBPS_FIRST_PAGE"));
	PRINT_SYLLABLE(pGBIS);
	PRINT_CANDS(pGBIS);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBHelperAddInputChar : %c \r\n", c_addInputString));
	retVal = GBHelperAddInputChar(pGBIS, c_addInputString);
	PRINTLOOKUPINFOMATION(retVal);
	GBGetPagedSyllable(pGBIS, GBPS_FIRST_PAGE);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetPagedSyllable : %s \r\n", "GBPS_FIRST_PAGE"));
	GBNextPageCandidate(pGBIS, 0);
	PRINT_SYLLABLE(pGBIS);
	PRINT_CANDS(pGBIS);
	PRINTFUNCTIONINFO_END(GBHelperAddInputChar);
}
SAMPLECODE_END(GBHelperAddInputChar)


SAMPLECODE_BEGIN(GBHelperAddInputString)
static void UT_GBHelperAddInputString(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	GBLPWCHAR c_inputString = L"96456456456456456456456456456";
	GBLPWCHAR c_addInputString = L"63";
	PRINTFUNCTIONINFO_BEGIN(GBHelperAddInputString);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	GBSetInputString(pGBIS, c_inputString);
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBSetInputString : %s \r\n", c_inputString));
	GBGetPagedSyllable(pGBIS, GBPS_FIRST_PAGE);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetPagedSyllable : %s \r\n", "GBPS_FIRST_PAGE"));
	PRINT_SYLLABLE(pGBIS);
	PRINT_CANDS(pGBIS);
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBHelperAddInputString : %s \r\n", c_addInputString));
	retVal = GBHelperAddInputString(pGBIS, c_addInputString);
	PRINTLOOKUPINFOMATION(retVal);
	GBGetPagedSyllable(pGBIS, GBPS_FIRST_PAGE);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetPagedSyllable : %s \r\n", "GBPS_FIRST_PAGE"));
	GBNextPageCandidate(pGBIS, 0);
	PRINT_SYLLABLE(pGBIS);
	PRINT_CANDS(pGBIS);
	PRINTFUNCTIONINFO_END(GBHelperAddInputString);
}
SAMPLECODE_END(GBHelperAddInputString)

//#Chinese 中文专门的函数

SAMPLECODE_BEGIN(GBGetAllSyllableCount)
// 仅对中文模糊拼音输入法有效
static void UT_GBGetAllSyllableCount(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBINT index = 0;
	GBINT sylCount = 0;
	GBWCHAR szSyllable[16] = {0};
	const GBWCHAR c_inputStr[] = {'9', '6', '6', '3', '6', 0};	// 输入“我们”

	PRINTFUNCTIONINFO_BEGIN(GBGetAllSyllableCount);
	// 设置语言及输入模式
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);

	wcscpy(pGBIS->inputString, c_inputStr);
	pGBIS->inputStringLen = (GBU8)wcslen(c_inputStr);
	pGBIS->flags |= GBIS_INPUT_STRING_UPDATED;
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Set input string = %s \r\n", "96636"));

	GBUpdateSyllable(pGBIS);
	retVal = GBGetAllSyllableCount(pGBIS, &sylCount);
	PRINTLOOKUPINFOMATION(retVal);	
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("syllable total = %d \r\n", sylCount));

	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("syllable list : ", sylCount));
	for (index = 1; index < sylCount + 1; index++)
	{
		GBACHAR buf[16] = {0};
		retVal = GBGetSyllable(pGBIS, index, szSyllable, ARRAY_DIM(szSyllable));
		_wcstombs(buf, szSyllable, sizeof(buf));
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("(%d) %s ", index, buf));
	}
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("\r\n"));

	PRINTFUNCTIONINFO_END(GBGetAllSyllableCount);
}
SAMPLECODE_END(GBGetAllSyllableCount)


SAMPLECODE_BEGIN(GBGetSyllable)
// 仅对中文模糊拼音输入法有效
static void UT_GBGetSyllable(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBWCHAR pSyllables[16];
	const GBWCHAR c_inputStr[] = {'9', '6', '6', '3', '6', 0};	// 输入“我们”
	const GBINT c_sylIndexArray[] = {1,3, 5};
	GBINT idx;

	PRINTFUNCTIONINFO_BEGIN(GBGetSyllable);

	// 设置语言及输入模式
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);

	wcscpy(pGBIS->inputString, c_inputStr);
	pGBIS->inputStringLen = (GBU8)wcslen(c_inputStr);
	pGBIS->flags |= GBIS_INPUT_STRING_UPDATED;
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Set input string = %s \r\n", "96636"));

	GBUpdateSyllable(pGBIS);
	for (idx = 0; idx < ARRAY_DIM(c_sylIndexArray); idx++)
	{
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Get syllable index = %d \r\n", c_sylIndexArray[idx]));
		retVal = GBGetSyllable(pGBIS, c_sylIndexArray[idx], pSyllables, ARRAY_DIM(pSyllables));
		PRINTLOOKUPINFOMATION(retVal);	
		if(GBOK == retVal)
		{
			GBACHAR syllable[128] = {0};
			wcstombs(syllable, pSyllables, sizeof(syllable));
			PT_PrintLogInfo(e_GBLOG_UNITTEST, ("pSyllables[%d] = %s \r\n", c_sylIndexArray[idx], syllable));
		}	
	}


	PRINTFUNCTIONINFO_END(GBGetSyllable);
}
SAMPLECODE_END(GBGetSyllable)


SAMPLECODE_BEGIN(GBSelectSyllable)
// 仅对中文模糊拼音输入法有效
static void UT_GBSelectSyllable(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	const GBWCHAR c_inputStr[] = {'9', '6', '6', '3', '6', 0};	// 输入“我们”
	const GBINT c_sylIndexArray[] = {1,3, 5};
	GBACHAR syllable[128] = {0};
	GBINT idx;
	GBAuxInfo * pAuxInfo = NULL;

	PRINTFUNCTIONINFO_BEGIN(GBSelectSyllable);

	// 设置语言及输入模式
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	GBSetEngineOption(pGBIS, GB_ENGINE_FUNCTION, GBFO_Chn_Up_To_Input_Key_Sequence, 1);
	wcscpy(pGBIS->inputString, c_inputStr);
	pGBIS->inputStringLen = (GBU8)wcslen(c_inputStr);
	pGBIS->flags |= GBIS_INPUT_STRING_UPDATED;
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Set input string = %s \r\n", "96636"));

	GBUpdateSyllable(pGBIS);
	retVal = GBGetPagedSyllable(pGBIS, GBPS_CURRENT_PAGE);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetPagedSyllable ret : %d\r\n", retVal));

	pAuxInfo = pGBIS->pAuxInfo;
	for (idx = 0; idx < pAuxInfo->nSyllableNum; idx++)
	{
		wcstombs(syllable, pAuxInfo->pSyllables[idx], sizeof(syllable));
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("%d. %s ", idx, syllable));
	}
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("\r\n"));
	for (idx = 0; idx < ARRAY_DIM(c_sylIndexArray); idx++)
	{
		retVal = GBSelectSyllable(pGBIS, c_sylIndexArray[idx]);
		//GBNextPageCandidate(pGBIS, 0);
		//GBGetCandidate(pGBIS, 0, 8);
		GBUpdateOutputInfo(pGBIS);
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("select syllable : %d\r\n", c_sylIndexArray[idx]));
		PRINTLOOKUPINFOMATION(retVal);
		if ( GBOK == retVal)
		{
			wcstombs(syllable, pAuxInfo->pSyllables[pAuxInfo->nSyllableIndex-pAuxInfo->nSyllablePageStartIndex], sizeof(syllable));
			PT_PrintLogInfo(e_GBLOG_UNITTEST, ("%d. %s \r\n", pAuxInfo->nSyllableIndex, syllable));
		}
	}
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("\r\n"));
	PRINTFUNCTIONINFO_END(GBSelectSyllable);
}
SAMPLECODE_END(GBSelectSyllable)


SAMPLECODE_BEGIN(GBSelectSyllableEx)
// 仅对中文模糊拼音输入法有效
static void UT_GBSelectSyllableEx(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	const GBWCHAR c_inputStr[] = {'9', '6', '6', '3', '6', 0};	// 输入“我们”
	GBLPCWCHAR c_pStrSyllable1 = L"WoMen";
	GBLPCWCHAR c_pStrSyllable2 = L"women";
	GBLPCWCHAR c_pStrSyllable3 = L"wo";
	GBLPCWCHAR c_pSylArray[] = {c_pStrSyllable1, c_pStrSyllable2, c_pStrSyllable3};
	GBINT idx = 0;

	PRINTFUNCTIONINFO_BEGIN(GBSelectSyllableEx);

	// 设置语言及输入模式
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);

	wcscpy(pGBIS->inputString, c_inputStr);
	pGBIS->inputStringLen = (GBU8)wcslen(c_inputStr);
	pGBIS->flags |= GBIS_INPUT_STRING_UPDATED;
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Set input string = %s \r\n", "96636"));

	GBUpdateSyllable(pGBIS);
	retVal = GBGetPagedSyllable(pGBIS, GBPS_CURRENT_PAGE);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetPagedSyllable ret : %d\r\n", retVal));

	for (idx = 0; idx < ARRAY_DIM(c_pSylArray); idx++)
	{
		GBACHAR syllable[64] = {0};
		wcstombs(syllable, c_pSylArray[idx], sizeof(syllable));
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Select Syllable = %s \r\n", syllable));
		retVal = GBSelectSyllableEx(pGBIS, c_pSylArray[idx]);
		PRINTLOOKUPINFOMATION(retVal);	
		if(GBOK == retVal)
		{
			GBAuxInfo * pAuxInfo = pGBIS->pAuxInfo;
			wcstombs(syllable, pAuxInfo->pSyllables[pAuxInfo->nSyllableIndex], sizeof(syllable));
			PT_PrintLogInfo(e_GBLOG_UNITTEST, ("syllable = %s index = %d \r\n", \
				syllable, pAuxInfo->nSyllableIndex));
		}
	}

	PRINTFUNCTIONINFO_END(GBSelectSyllableEx);
}
SAMPLECODE_END(GBSelectSyllableEx)


SAMPLECODE_BEGIN(GBGetSyllables)
static void UT_GBGetSyllables(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	const GBWCHAR c_inputStr[] = {'9', '6', '6', '3', '6', 0};	// 输入“我们”
	GBINT count;
	GBWCHAR *pSyllables[64];
	GBACHAR syllable[128] = {0};

	PRINTFUNCTIONINFO_BEGIN(GBGetSyllables);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);

	wcscpy(pGBIS->inputString, c_inputStr);
	pGBIS->inputStringLen = (GBU8)wcslen(c_inputStr);
	pGBIS->flags |= GBIS_INPUT_STRING_UPDATED;

	GBUpdateSyllable(pGBIS);
	retVal = GBGetAllSyllableCount(pGBIS, &count);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetAllSyllableCount ret = %d\r\n", retVal));
	retVal = GBGetSyllables(pGBIS, 0, pSyllables, ARRAY_DIM(pSyllables));
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetSyllables ret = %d\r\n", retVal));
	PRINTLOOKUPINFOMATION(retVal);
	if(GBOK == retVal && count > 0)
	{
		GBINT idx;
		printf("syllable list: ");
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Syllable Couont = %d \r\n", count));
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Syllable list: \r\n"));
		for(idx = 0; idx < count; idx++)
		{
			wcstombs(syllable, pSyllables[idx], sizeof(syllable));
			PT_PrintLogInfo(e_GBLOG_UNITTEST, ("index = %d syllable = %s \r\n", idx+1, syllable));
		}
		PT_PrintLogInfo(e_GBLOG_UNITTEST, (" \r\n"));
	}
	PRINTFUNCTIONINFO_END(GBGetSyllables);
}
SAMPLECODE_END(GBGetSyllables)


SAMPLECODE_BEGIN(GBUpdateSyllable)
static void UT_GBUpdateSyllable(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBINT idx;
	GBACHAR syllable[128] = {0};
	const GBWCHAR c_inputStr[] = {'9', '6', '6', '3', '6', 0};	// 输入“我们”
	GBAuxInfo * pAuxInfo;

	PRINTFUNCTIONINFO_BEGIN(GBUpdateSyllable);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);

	wcscpy(pGBIS->inputString, c_inputStr);
	pGBIS->inputStringLen = (GBU8)wcslen(c_inputStr);
	pGBIS->flags |= GBIS_INPUT_STRING_UPDATED;

	retVal = GBUpdateSyllable(pGBIS);
	PRINTLOOKUPINFOMATION(retVal);
	retVal = GBGetPagedSyllable(pGBIS, GBPS_CURRENT_PAGE);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetPagedSyllable ret = %d \r\n", retVal));
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Syllable list: \r\n"));
	pAuxInfo = pGBIS->pAuxInfo;
	for(idx = 0; idx < pAuxInfo->nSyllableNum; idx++)
	{
		wcstombs(syllable, pAuxInfo->pSyllables[idx], wcslen(pAuxInfo->pSyllables[idx]));
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("index = %d syllable = %s \r\n", idx+1, syllable));
	}
	PT_PrintLogInfo(e_GBLOG_UNITTEST, (" \r\n"));
	PRINTFUNCTIONINFO_END(GBUpdateSyllable);
}
SAMPLECODE_END(GBUpdateSyllable)


SAMPLECODE_BEGIN(GBGeSyllablePageCount)
static void UT_GBGeSyllablePageCount(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBINT nSylPageCount = 0;
	PRINTFUNCTIONINFO_BEGIN(GBGeSyllablePageCount);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	SET_INPUT_STRING(pGBIS, L"96636");
	GBNextPageCandidate(pGBIS, 0);
	retVal = GBGeSyllablePageCount(pGBIS, &nSylPageCount);
	if(GBOK == GBGetPagedSyllable(pGBIS, GBPS_FIRST_PAGE))
	{
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetPagedSyllable [%s]\r\n", "GBPS_FIRST_PAGE"));
		PRINT_SYLLABLE(pGBIS);
		while (GBOK == GBGetPagedSyllable(pGBIS, GBPS_NEXT_PAGE))
		{
			PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetPagedSyllable [%s]\r\n", "GBPS_NEXT_PAGE"));
			PRINT_SYLLABLE(pGBIS);
		}
	}
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("syllable page count : %d ,ret = %d\r\n", nSylPageCount, retVal));
	PRINTFUNCTIONINFO_END(GBGeSyllablePageCount);
}
SAMPLECODE_END(GBGeSyllablePageCount)


SAMPLECODE_BEGIN(GBGetCurrentSyllablePageIndex)
static void UT_GBGetCurrentSyllablePageIndex(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBINT nPageIndex;
	PRINTFUNCTIONINFO_BEGIN(GBGetCurrentSyllablePageIndex);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	SET_INPUT_STRING(pGBIS, L"96636");
	GBNextPageCandidate(pGBIS, 0);
	retVal = GBGetCurrentSyllablePageIndex(pGBIS, &nPageIndex);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("current syllable page index : %d ,ret = %d\r\n", nPageIndex, retVal));
	PRINTLOOKUPINFOMATION(retVal);
	PRINTFUNCTIONINFO_END(GBGetCurrentSyllablePageIndex);
}
SAMPLECODE_END(GBGetCurrentSyllablePageIndex)


SAMPLECODE_BEGIN(GBSetFuzzy)
static void UT_GBSetFuzzy(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	PRINTFUNCTIONINFO_BEGIN(GBSetFuzzy);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Qwerty_Pinyin);

	retVal = GBSetFuzzy(pGBIS, GBCFG_PINYIN_FUZZY_H_F, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("turn off setting GBCFG_PINYIN_FUZZY_N_L \r\n"));
	PRINTLOOKUPINFOMATION(retVal);

	SET_INPUT_STRING(pGBIS, L"fei");
	GBNextPageCandidate(pGBIS, 0);
	PRINT_CANDS(pGBIS);

	GBReset(pGBIS);

	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("turn on setting GBCFG_PINYIN_FUZZY_N_L \r\n"));
	retVal = GBSetFuzzy(pGBIS, GBCFG_PINYIN_FUZZY_H_F, 1);
	PRINTLOOKUPINFOMATION(retVal);

	SET_INPUT_STRING(pGBIS, L"fei");
	GBNextPageCandidate(pGBIS, 0);
	PRINT_CANDS(pGBIS);


	PRINTFUNCTIONINFO_END(GBSetFuzzy);
}
SAMPLECODE_END(GBSetFuzzy)


SAMPLECODE_BEGIN(GBWord2CodesByInputmod)
static void UT_GBWord2CodesByInputmod(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBWCHAR pBuff[32] = {0};
	GBACHAR syllable[128] = {0};
	const GBINT16 isn[] = {L'我', L'还'};
	GBINT idx;
	PRINTFUNCTIONINFO_BEGIN(GBWord2CodesByInputmod);

	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Get Pinyin:\r\n"));
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	for (idx=0; idx < ARRAY_DIM(isn); idx++)
	{
		GBINT sylIdx;
		for (sylIdx=0; sylIdx < 3; sylIdx++)
		{
			GBINT16 tempIsn[2] = {0};
			tempIsn[0] = isn[idx];
			memset(syllable, 0, sizeof(syllable));
			_wcstombs(syllable, tempIsn, sizeof(syllable));
			PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Word is = %s, syllable index = %d \r\n", syllable, sylIdx));
			retVal = GBWord2CodesByInputmod(pGBIS, GBIM_Pinyin, isn[idx], sylIdx, pBuff);
			PRINTLOOKUPINFOMATION(retVal);
			if(GBOK == retVal)
			{
				memset(syllable, 0, sizeof(syllable));
				wcstombs(syllable, pBuff, wcslen(pBuff));
				PT_PrintLogInfo(e_GBLOG_UNITTEST, ("reverse code is = %s \r\n", syllable));
			}
		}
	}
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Get Stroke:\r\n"));
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Stroke);
	for (idx=0; idx < ARRAY_DIM(isn); idx++)
	{
		GBINT sylIdx;
		for (sylIdx=0; sylIdx < 3; sylIdx++)
		{
			GBINT16 tempIsn[2] = {0};
			tempIsn[0] = isn[idx];
			memset(syllable, 0, sizeof(syllable));
			_wcstombs(syllable, tempIsn, sizeof(syllable));
			PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Word is = %s, syllable index = %d \r\n", syllable, sylIdx));
			retVal = GBWord2CodesByInputmod(pGBIS, GBIM_Stroke, isn[idx], sylIdx, pBuff);
			PRINTLOOKUPINFOMATION(retVal);
			if(GBOK == retVal)
			{
				memset(syllable, 0, sizeof(syllable));
				wcstombs(syllable, pBuff, wcslen(pBuff));
				PT_PrintLogInfo(e_GBLOG_UNITTEST, ("reverse code is = %s \r\n", syllable));
			}
		}
	}

	PRINTFUNCTIONINFO_END(GBWord2CodesByInputmod);
}
SAMPLECODE_END(GBWord2CodesByInputmod)


SAMPLECODE_BEGIN(GBTranslateInputStringToSyllable)
// 仅对中文模糊拼音输入法有效
static void UT_GBTranslateInputStringToSyllable(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBWCHAR pBuff[128] = {0};
	GBACHAR syllable[128] = {0};
	const GBWCHAR c_inputStr[] = {'9', '6', '6', '3', '6', 0};	// 输入“我们”

	PRINTFUNCTIONINFO_BEGIN(GBTranslateInputStringToSyllable);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	SET_INPUT_STRING(pGBIS, c_inputStr);

	retVal = GBTranslateInputStringToSyllable(pGBIS, pBuff, sizeof(pBuff));
	PRINTLOOKUPINFOMATION(retVal);
	if(GBOK == retVal)
	{
		//wcstombs(syllable, pBuff, sizeof(syllable));
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"translate to syllable is = %s \r\n", pBuff));
	}
	PRINTFUNCTIONINFO_END(GBTranslateInputStringToSyllable);
}
SAMPLECODE_END(GBTranslateInputStringToSyllable)


SAMPLECODE_BEGIN(GBChnGetAfterChar)
// 适用于中文输入模式GBIM_Qwerty_Pinyin、GBIM_Explicit_Bopomofo 、GBIM_Qwerty_Jyutping
static void UT_GBChnGetAfterChar(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBWCHAR pBuff[128] = {0};
	GBACHAR syllable[128] = {0};
	const GBWCHAR c_inputStr_Qwerty[] = {'z', 'h', 0};

	PRINTFUNCTIONINFO_BEGIN(GBChnGetAfterChar);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Qwerty_Pinyin);

	retVal = GBChnGetAfterChar(pGBIS, GBIM_Qwerty_Pinyin, c_inputStr_Qwerty, pBuff, sizeof(pBuff));
	PRINTLOOKUPINFOMATION(retVal);
	if(GBOK == retVal)
	{
		//wcstombs(syllable, pBuff, wcslen(pBuff));
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L" \"%s\" After char is = %s \r\n", c_inputStr_Qwerty, pBuff));
	}
	PRINTFUNCTIONINFO_END(GBChnGetAfterChar);
}
SAMPLECODE_END(GBChnGetAfterChar)


SAMPLECODE_BEGIN(GBSetEngineOption)
static void UT_GBSetEngineOption(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	PRINTFUNCTIONINFO_BEGIN(GBSetEngineOption);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Set engine option :%s, %s, %d\r\n", "GB_ENGINE_CHINESE", "GBCFG_CLOSE_COMPONENT", 1));
	retVal = GBSetEngineOption(pGBIS, GB_ENGINE_CHINESE, GBCFG_CLOSE_COMPONENT, 1);
	PRINTLOOKUPINFOMATION(retVal);
	PRINTFUNCTIONINFO_END(GBSetEngineOption);
}
SAMPLECODE_END(GBSetEngineOption)


SAMPLECODE_BEGIN(GBGetEngineOption)
static void UT_GBGetEngineOption(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBU32 option;
	PRINTFUNCTIONINFO_BEGIN(GBGetEngineOption);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Get engine option :%s, %s\r\n", "GB_ENGINE_CHINESE", "GBCFG_CLOSE_COMPONENT"));
	retVal = GBGetEngineOption(pGBIS, GB_ENGINE_CHINESE, GBCFG_CLOSE_COMPONENT, &option);
	PRINTLOOKUPINFOMATION(retVal);
	if(GBOK == retVal)
	{
		PT_PrintLogInfo(e_GBLOG_UNITTEST, (" Current engine option is %d \r\n", option));
	}
	PRINTFUNCTIONINFO_END(GBGetEngineOption);
}
SAMPLECODE_END(GBGetEngineOption)


SAMPLECODE_BEGIN(GBGetPagedSyllable)
// 仅对中文模糊拼音输入法有效
static void UT_GBGetPagedSyllable(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBINT idx;
	GBACHAR syllable[128] = {0};
	const GBWCHAR c_inputStr[] = {'9', '6', '6', '3', '6', 0};	// 输入“我们”
	GBAuxInfo * pAuxInfo;
	PRINTFUNCTIONINFO_BEGIN(GBGetPagedSyllable);
	// 设置语言及输入模式
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	SET_INPUT_STRING(pGBIS, c_inputStr);

	GBUpdateSyllable(pGBIS);
	retVal = GBGetPagedSyllable(pGBIS, GBPS_NEXT_PAGE);
	PRINTLOOKUPINFOMATION(retVal);
	pAuxInfo = pGBIS->pAuxInfo;
	PT_PrintLogInfo(e_GBLOG_UNITTEST, (" Syllable Number = %d, list: \r\n", pAuxInfo->nSyllableNum));
	for(idx = 0; idx < pAuxInfo->nSyllableNum; idx++)
	{
// 		wcstombs(syllable, pAuxInfo->pSyllables[idx], wcslen(pAuxInfo->pSyllables[idx]));
// 		PT_PrintLogInfo(e_GBLOG_UNITTEST, (" %d : %s \r\n", idx+1, syllable));
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L" %d : %s \r\n", idx+1, pAuxInfo->pSyllables[idx]));
	}
	PT_PrintLogInfo(e_GBLOG_UNITTEST, (" \r\n"));
	PRINTFUNCTIONINFO_END(GBGetPagedSyllable);
}
SAMPLECODE_END(GBGetPagedSyllable)


SAMPLECODE_BEGIN(GBChnGetComponents)
static void UT_GBChnGetComponents(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBACHAR component[128] = {0};
	const GBWCHAR c_inputStr[] = {'1', '2', 0};
	GBAuxInfo * pAuxInfo;
	PRINTFUNCTIONINFO_BEGIN(GBChnGetComponents);
	// 设置语言及输入模式
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Stroke);
	SET_INPUT_STRING(pGBIS, c_inputStr);

	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Set engine option :%s, %s, %d\r\n", "GB_ENGINE_CHINESE", "GBCFG_CLOSE_COMPONENT", 0));
	GBSetEngineOption(pGBIS, GB_ENGINE_CHINESE, GBCFG_CLOSE_COMPONENT, 0);
	retVal = GBNextPageCandidate(pGBIS, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBNextPageCandidate : ret = %d\r\n", retVal));
	retVal = GBChnGetComponents(pGBIS);
	PRINTLOOKUPINFOMATION(retVal);
	if(GBOK == retVal)
	{
		pAuxInfo = pGBIS->pAuxInfo;
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"current component is:%s \r\n", pAuxInfo->wComponents));
	}
	PRINTFUNCTIONINFO_END(GBChnGetComponents);
}
SAMPLECODE_END(GBChnGetComponents)


SAMPLECODE_BEGIN(GBSetAssocWord)
static void UT_GBSetAssocWord(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	PRINTFUNCTIONINFO_BEGIN(GBSetAssocWord);
	// 设置语言及输入模式
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	pGBIS->nCandType |= GBCT_Associate;
	retVal = GBSetAssocWord(pGBIS, L"奥", TRUE);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Set assoc word : %s, %s\r\n", "奥", "TRUE"));
	PRINTLOOKUPINFOMATION(retVal);
	retVal = GBSetAssocWord(pGBIS, L"林", FALSE);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Set assoc word : %s, %s\r\n", "林", "FALSE"));
	PRINTLOOKUPINFOMATION(retVal);
	retVal = GBNextPageCandidate(pGBIS, 0);
	if(GBOK == retVal)
	{
		GBINT idx;
		GBOutputInfo * pOutputInfo = &pGBIS->outputInfo;
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Associate cand num = %d \r\n", pOutputInfo->nCandNum));
		for(idx = 0; idx < pOutputInfo->nCandNum; idx++)
		{
			PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"%d:%s \r\n", idx, pOutputInfo->pCandidates[idx]));
		}
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("\r\n"));
	}
	PRINTFUNCTIONINFO_END(GBSetAssocWord);
}
SAMPLECODE_END(GBSetAssocWord)


SAMPLECODE_BEGIN(GBGetAssocWord)
static void UT_GBGetAssocWord(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	PRINTFUNCTIONINFO_BEGIN(GBGetAssocWord);
	// 设置语言及输入模式
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);

	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Get assoc word : %s, %s\r\n", "奥", "TRUE"));
	retVal = GBGetAssocWord(pGBIS, L"奥", TRUE);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Get assoc word : %s, %s\r\n", "林", "FALSE"));
	retVal = GBGetAssocWord(pGBIS, L"林", FALSE);
	PRINTLOOKUPINFOMATION(retVal);
	if(GBOK == retVal)
	{
		GBINT idx;
		GBOutputInfo * pOutputInfo = &pGBIS->outputInfo;
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("Associate cand num = %d \r\n", pOutputInfo->nCandNum));
		for(idx = 0; idx < pOutputInfo->nCandNum; idx++)
		{
			PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"%d:%s \r\n", idx, pOutputInfo->pCandidates[idx]));
		}
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("\r\n"));
	}
	PRINTFUNCTIONINFO_END(GBGetAssocWord);
}
SAMPLECODE_END(GBGetAssocWord)


SAMPLECODE_BEGIN(GBSetSyllableTone)
static void UT_GBSetSyllableTone(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBPWCHAR c_inputStr = L"64";

	PRINTFUNCTIONINFO_BEGIN(GBSetSyllableTone);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	SET_INPUT_STRING(pGBIS, c_inputStr);

	GBNextPageCandidate(pGBIS, 0);
	PRINT_CANDS(pGBIS);
	GBReset(pGBIS);
	SET_INPUT_STRING(pGBIS, c_inputStr);
	retVal = GBSetSyllableTone(pGBIS, GB_CHN_TONE_4);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBSetSyllableTone : %s\r\n", "GB_CHN_TONE_4"));
	GBNextPageCandidate(pGBIS, 0);
	PRINT_CANDS(pGBIS);
	PRINTFUNCTIONINFO_END(GBSetSyllableTone);
}
SAMPLECODE_END(GBSetSyllableTone)

//#Alphabetic Alphabetic专门的函数

SAMPLECODE_BEGIN(GBGetDesireOutput)
static void UT_GBGetDesireOutput(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBACHAR candidate[128] = {0};
	const GBWCHAR c_inputStr[] = {'4', '6', '6', '3', 0};	// 输入"good"
	PRINTFUNCTIONINFO_BEGIN(GBGetDesireOutput);
	SET_INPUT_MODE(pGBIS, GBL_English, 0, GBIM_Predictive);
	SET_INPUT_STRING(pGBIS, c_inputStr);

	retVal = GBNextPageCandidate(pGBIS, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBNextPageCandidate : ret = %d \r\n", retVal));
	if(GBOK == retVal)
	{
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"current output candidate[0]: %s \r\n", pGBIS->outputInfo.pCandidates[0]));
	}
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetDesireOutput : %s \r\n", "GBA_OUTPUT_FCC"));
	retVal = GBGetDesireOutput(pGBIS, GBA_OUTPUT_FCC);
	PRINTLOOKUPINFOMATION(retVal);
	if(GBOK == retVal)
	{
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"current output candidate[0]: %s \r\n", pGBIS->outputInfo.pCandidates[0]));
	}
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetDesireOutput : %s \r\n", "GBA_OUTPUT_CAPITAL"));
	retVal = GBGetDesireOutput(pGBIS, GBA_OUTPUT_CAPITAL);
	PRINTLOOKUPINFOMATION(retVal);
	if(GBOK == retVal)
	{
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"current output candidate[0]: %s \r\n", pGBIS->outputInfo.pCandidates[0]));
	}
	PRINTFUNCTIONINFO_END(GBGetDesireOutput);
}
SAMPLECODE_END(GBGetDesireOutput)


SAMPLECODE_BEGIN(GBConvertChar)
static void UT_GBConvertChar(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBWCHAR pBuff[128] = {0};
	GBACHAR pOutput[128] = {0};
	const GBWCHAR c_inputStr[] = {'4', '6', '6', '3', 0};	// 输入"good"
	PRINTFUNCTIONINFO_BEGIN(GBConvertChar);
	SET_INPUT_MODE(pGBIS, GBL_English, 0, GBIM_Predictive);
	SET_INPUT_STRING(pGBIS, c_inputStr);

	retVal = GBNextPageCandidate(pGBIS, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBNextPageCandidate : ret = %d \r\n", retVal));

	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"current pCandidates[0]: %s \r\n", pGBIS->outputInfo.pCandidates[0]));

	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBConvertChar : %s \r\n", "GBA_OUTPUT_CAPITAL"));
	wcscpy(pBuff, pGBIS->outputInfo.pCandidates[0]);
	retVal = GBConvertChar(pGBIS, pBuff, GBA_OUTPUT_CAPITAL);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"current pCandidates[0]: %s \r\n", pBuff));
	PRINTFUNCTIONINFO_END(GBConvertChar);
}
SAMPLECODE_END(GBConvertChar)


SAMPLECODE_BEGIN(GBConvertString)
static void UT_GBConvertString(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBWCHAR c_inputStr[] = {'4', '6', '6', '3', 0};	// 输入"good"
	PRINTFUNCTIONINFO_BEGIN(GBConvertString);
	SET_INPUT_MODE(pGBIS, GBL_English, 0, GBIM_Predictive);
	SET_INPUT_STRING(pGBIS, c_inputStr);
	retVal = GBNextPageCandidate(pGBIS, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBNextPageCandidate : ret = %d \r\n", retVal));
	PRINT_CANDS(pGBIS);

	retVal = GBConvertString(pGBIS, pGBIS->outputInfo.pCandidates[0], GBA_OUTPUT_CAPITAL);
	PRINTLOOKUPINFOMATION(retVal);
	PRINT_CANDS(pGBIS);

	PRINTFUNCTIONINFO_END(GBConvertString);
}
SAMPLECODE_END(GBConvertString)


SAMPLECODE_BEGIN(GBConvertStringToNumPadKeySequence)
static void UT_GBConvertStringToNumPadKeySequence(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBWCHAR pBuff[128] = {0};
	PRINTFUNCTIONINFO_BEGIN(GBConvertStringToNumPadKeySequence);

	SET_INPUT_MODE(pGBIS, GBL_English, 0, GBIM_Predictive);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBConvertStringToNumPadKeySequence: %s \r\n", "good"));
	retVal = GBConvertStringToNumPadKeySequence(pGBIS, L"good", pBuff, sizeof(pBuff));
	PRINTLOOKUPINFOMATION(retVal);
	if(GBOK == retVal)
	{
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"current output: %s \r\n", pBuff));
	}
	PRINTFUNCTIONINFO_END(GBConvertStringToNumPadKeySequence);
}
SAMPLECODE_END(GBConvertStringToNumPadKeySequence)


SAMPLECODE_BEGIN(GBTransform)
static void UT_GBTransform(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBWCHAR buf[128] = {0};
	PRINTFUNCTIONINFO_BEGIN(GBTransform);
	retVal = GBTransform(GBL_Vietnamese, L"đơkâêbaaaaaâđa", buf, ARRAY_DIM(buf));
	//PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBTransform : GBL_Vietnamese \"%s\" from \"%s\"\r\n", L"đơkâêbaaaaaâđa", buf));
	retVal = GBTransform(GBL_Uighur, L"بولمايدۇ", buf, ARRAY_DIM(buf));
	//PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBTransform : GBL_Uighur \"%s\" from \"%s\"\r\n", L"بولمايدۇ", buf));
	PRINTFUNCTIONINFO_END(GBTransform);
}
SAMPLECODE_END(GBTransform)


SAMPLECODE_BEGIN(GBTransformReverse)
static void UT_GBTransformReverse(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBWCHAR buf[128] = {0};
	PRINTFUNCTIONINFO_BEGIN(GBTransformReverse);
	retVal = GBTransformReverse(GBL_Vietnamese, L"đơkâêbaaaaaâđa", buf, ARRAY_DIM(buf));
	//PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBTransform : GBL_Vietnamese \"%s\" from \"%s\"\r\n", L"đơkâêbaaaaaâđa", buf));
	retVal = GBTransformReverse(GBL_Uighur, L"بولمايدۇ", buf, ARRAY_DIM(buf));
	//PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBTransform : GBL_Uighur \"%s\" from \"%s\"\r\n", L"بولمايدۇ", buf));
	PRINTFUNCTIONINFO_END(GBTransformReverse);
}
SAMPLECODE_END(GBTransformReverse)


SAMPLECODE_BEGIN(GBSetShiftCap)
static void UT_GBSetShiftCap(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBACHAR pOutput[128] = {0};
	const GBWCHAR c_inputStr[] = {'4', '6', '6', '3', 0};	// 输入"good"
	PRINTFUNCTIONINFO_BEGIN(GBSetShiftCap);
	SET_INPUT_MODE(pGBIS, GBL_English, 0, GBIM_Predictive);
	SET_INPUT_STRING(pGBIS, c_inputStr);

	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBSetShiftCap: Shift=%s, CapsLock=%s \r\n", "TRUE", "FALSE"));
	retVal = GBSetShiftCap(pGBIS, TRUE, FALSE);
	PRINTLOOKUPINFOMATION(retVal);
	retVal = GBNextPageCandidate(pGBIS, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBNextPageCandidate : ret = %d \r\n", retVal));
	if(GBOK == retVal)
	{
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"current pCandidates[0]: %s \r\n", pGBIS->outputInfo.pCandidates[0]));
	}

	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBSetShiftCap: Shift=%s, CapsLock=%s \r\n", "TRUE", "TRUE"));
	retVal = GBSetShiftCap(pGBIS, TRUE, TRUE);
	PRINTLOOKUPINFOMATION(retVal);
	retVal = GBNextPageCandidate(pGBIS, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBNextPageCandidate : ret = %d \r\n", retVal));
	if(GBOK == retVal)
	{
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"current pCandidates[0]: %s \r\n", pGBIS->outputInfo.pCandidates[0]));
	}
	PRINTFUNCTIONINFO_END(GBSetShiftCap);
}
SAMPLECODE_END(GBSetShiftCap)


SAMPLECODE_BEGIN(GBAlpGetValidInputStr)
static void UT_GBAlpGetValidInputStr(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBPCCHAR pValidStr;
	PRINTFUNCTIONINFO_BEGIN(GBAlpGetValidInputStr);
	SET_INPUT_MODE(pGBIS, GBL_English, 0, GBIM_Predictive);
	retVal = GBAlpGetValidInputStr(pGBIS, GBIM_Predictive, GBCT_Normal, &pValidStr);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBAlpGetValidInputStr : GBIM_Predictive, GBCT_Normal, %s\r\n", pValidStr));
	PRINTFUNCTIONINFO_END(GBAlpGetValidInputStr);
}
SAMPLECODE_END(GBAlpGetValidInputStr)


SAMPLECODE_BEGIN(GBALPSetAbbreviateWordTreeEnable)
static void UT_GBALPSetAbbreviateWordTreeEnable(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	PRINTFUNCTIONINFO_BEGIN(GBALPSetAbbreviateWordTreeEnable);
	SET_INPUT_MODE(pGBIS, GBL_English, 0, GBIM_Predictive);
	retVal = GBALPSetAbbreviateWordTreeEnable(pGBIS, 1);
	PRINTLOOKUPINFOMATIONEX(GBE_ALP_ENGINE_RET, retVal);
	PRINTFUNCTIONINFO_END(GBALPSetAbbreviateWordTreeEnable);
}
SAMPLECODE_END(GBALPSetAbbreviateWordTreeEnable)

//#Candidate 获取候选的API

SAMPLECODE_BEGIN(GBHaveNextPage)
static void UT_GBHaveNextPage(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	PRINTFUNCTIONINFO_BEGIN(GBHaveNextPage);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	GBMMIHandleKeyEvent(pGBIS, L'2', 0);
	retVal = GBHaveNextPage(pGBIS);
	PRINTLOOKUPINFOMATION(retVal);
	PRINTFUNCTIONINFO_END(GBHaveNextPage);
}
SAMPLECODE_END(GBHaveNextPage)


SAMPLECODE_BEGIN(GBHavePrevPage)
static void UT_GBHavePrevPage(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	PRINTFUNCTIONINFO_BEGIN(GBHavePrevPage);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	GBMMIHandleKeyEvent(pGBIS, L'2', 0);
	retVal = GBHavePrevPage(pGBIS);
	PRINTLOOKUPINFOMATION(retVal);
	PRINTFUNCTIONINFO_END(GBHavePrevPage);
}
SAMPLECODE_END(GBHavePrevPage)


SAMPLECODE_BEGIN(GBNextPageCandidate)
static void UT_GBNextPageCandidate(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBPWCHAR c_inputStr = L"64426";
	PRINTFUNCTIONINFO_BEGIN(GBNextPageCandidate);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	SET_INPUT_STRING(pGBIS, c_inputStr);
	retVal = GBNextPageCandidate(pGBIS, 0);
	PRINTLOOKUPINFOMATION(retVal);
	PRINT_CANDS(pGBIS);
	PRINTFUNCTIONINFO_END(GBNextPageCandidate);
}
SAMPLECODE_END(GBNextPageCandidate)


SAMPLECODE_BEGIN(GBNextPageCandidateEx)
static void UT_GBNextPageCandidateEx(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBPWCHAR c_inputStr = L"64426";
	PRINTFUNCTIONINFO_BEGIN(GBNextPageCandidateEx);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	SET_INPUT_STRING(pGBIS, c_inputStr);
	retVal = GBNextPageCandidateEx(pGBIS, 0, 0);
	PRINTLOOKUPINFOMATION(retVal);
	PRINT_CANDS(pGBIS);
	retVal = GBNextPageCandidateEx(pGBIS, 7, 1);
	PRINTLOOKUPINFOMATION(retVal);
	PRINT_CANDS(pGBIS);
	PRINTFUNCTIONINFO_END(GBNextPageCandidateEx);
}
SAMPLECODE_END(GBNextPageCandidateEx)


SAMPLECODE_BEGIN(GBPrevPageCandidate)
static void UT_GBPrevPageCandidate(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBPWCHAR c_inputStr = L"64426";
	PRINTFUNCTIONINFO_BEGIN(GBPrevPageCandidate);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	SET_INPUT_STRING(pGBIS, c_inputStr);

	retVal = GBNextPageCandidateEx(pGBIS, 7, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBNextPageCandidateEx : %d\r\n", retVal));
	PRINT_CANDS(pGBIS);

	retVal = GBPrevPageCandidate(pGBIS, 6);
	PRINTLOOKUPINFOMATION(retVal);
	PRINT_CANDS(pGBIS);

	PRINTFUNCTIONINFO_END(GBPrevPageCandidate);
}
SAMPLECODE_END(GBPrevPageCandidate)


SAMPLECODE_BEGIN(GBCurPageCandidateEx)
static void UT_GBCurPageCandidateEx(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBPWCHAR c_inputStr = L"64426";
	PRINTFUNCTIONINFO_BEGIN(GBCurPageCandidateEx);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	SET_INPUT_STRING(pGBIS, c_inputStr);

	retVal = GBCurPageCandidateEx(pGBIS, 0, 0);
	PRINTLOOKUPINFOMATION(retVal);
	PRINT_CANDS(pGBIS);
	retVal = GBCurPageCandidateEx(pGBIS, 7, 1);
	PRINTLOOKUPINFOMATION(retVal);
	PRINT_CANDS(pGBIS);
	PRINTFUNCTIONINFO_END(GBCurPageCandidateEx);
}
SAMPLECODE_END(GBCurPageCandidateEx)


SAMPLECODE_BEGIN(GBCurPageCandidate)
static void UT_GBCurPageCandidate(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBPWCHAR c_inputStr = L"64426";
	PRINTFUNCTIONINFO_BEGIN(GBCurPageCandidate);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	SET_INPUT_STRING(pGBIS, c_inputStr);

	retVal = GBCurPageCandidate(pGBIS, 0);
	PRINTLOOKUPINFOMATION(retVal);
	PRINT_CANDS(pGBIS);
	PRINTFUNCTIONINFO_END(GBCurPageCandidate);
}
SAMPLECODE_END(GBCurPageCandidate)


SAMPLECODE_BEGIN(GBSelectCandidate)
static void UT_GBSelectCandidate(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBPWCHAR c_inputStr = L"64426";
	PRINTFUNCTIONINFO_BEGIN(GBSelectCandidate);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	SET_INPUT_STRING(pGBIS, c_inputStr);

	retVal = GBCurPageCandidate(pGBIS, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBCurPageCandidate : %d\r\n", retVal));
	if (pGBIS->outputInfo.nCandNum == 0)
	{
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("cand count %d\r\n", pGBIS->outputInfo.nCandNum));
		return;
	}
	PRINT_CANDS(pGBIS);

	retVal = GBSelectCandidate(pGBIS, pGBIS->outputInfo.pCandidates[0]);
	PRINTLOOKUPINFOMATION(retVal);
	if (pGBIS->outputInfo.pUpScreenStr == NULL)
	{
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("up screen str == NULL %d\r\n"));
		return;
	}
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBSelectCandidate : %d, %s\r\n", retVal, pGBIS->outputInfo.pUpScreenStr));

	PRINTFUNCTIONINFO_END(GBSelectCandidate);
}
SAMPLECODE_END(GBSelectCandidate)


SAMPLECODE_BEGIN(GBSelectCandidateEx)
static void UT_GBSelectCandidateEx(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBPWCHAR c_inputStr = L"6442662";
	PRINTFUNCTIONINFO_BEGIN(GBSelectCandidateEx);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	SET_INPUT_STRING(pGBIS, c_inputStr);
	retVal = GBCurPageCandidate(pGBIS, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBCurPageCandidate : %d\r\n", retVal));
	if (pGBIS->outputInfo.nCandNum == 0)
	{
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("cand count %d\r\n", pGBIS->outputInfo.nCandNum));
		return;
	}
	PRINT_CANDS(pGBIS);

	retVal = GBSelectCandidateEx(pGBIS, L"你好", 5);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfoW(e_GBLOG_UNITTEST
		, (L"select cand %s and input len is %d, output is %s\r\n", L"你好", 5, pGBIS->pAuxInfo->pOutputString));
	PRINTFUNCTIONINFO_END(GBSelectCandidateEx);
}
SAMPLECODE_END(GBSelectCandidateEx)


SAMPLECODE_BEGIN(GBCancelSelectCandidate)
static void UT_GBCancelSelectCandidate(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBPWCHAR c_inputStr = L"6442662";
	PRINTFUNCTIONINFO_BEGIN(GBCancelSelectCandidate);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	SET_INPUT_STRING(pGBIS, c_inputStr);
	retVal = GBCurPageCandidate(pGBIS, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBCurPageCandidate : %d\r\n", retVal));
	if (pGBIS->outputInfo.nCandNum == 0)
	{
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("cand count %d\r\n", pGBIS->outputInfo.nCandNum));
		return;
	}
	PRINT_CANDS(pGBIS);
	retVal = GBSelectCandidateEx(pGBIS, L"你好", 5);
	PT_PrintLogInfoW(e_GBLOG_UNITTEST
		, (L"GBSelectCandidateEx : ret=%d, select cand %s and input len is %d, output is %s\r\n", retVal, L"你好", 5, pGBIS->pAuxInfo->pOutputString));
	retVal = GBCancelSelectCandidate(pGBIS);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfoW(e_GBLOG_UNITTEST
		, (L"cancel select cand %s, output is %s\r\n", L"你好", pGBIS->pAuxInfo->pOutputString));
	PRINTFUNCTIONINFO_END(GBCancelSelectCandidate);
}
SAMPLECODE_END(GBCancelSelectCandidate)


SAMPLECODE_BEGIN(GBSetCandBuffer)
static void UT_GBSetCandBuffer(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	int i = 0;
	GBWCHAR szCand[16] = {0};
	int iCandLen = 0;
	GBWCHAR szCandBuffer[256] = {0};
	GBPWCHAR pCandBuf = NULL;
	GBPWCHAR c_inputStr = L"6442662";
	PRINTFUNCTIONINFO_BEGIN(GBSetCandBuffer);
	retVal = GBSetCandBuffer(pGBIS, szCandBuffer, sizeof(szCandBuffer));
	PRINTLOOKUPINFOMATION(retVal);

	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	SET_INPUT_STRING(pGBIS, c_inputStr);
	retVal = GBCurPageCandidate(pGBIS, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBCurPageCandidate : %d\r\n", retVal));

	pCandBuf = szCandBuffer;
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBSetCandBuffer : "));
	for (i = 0; i < pGBIS->outputInfo.nCandNum; i++)
	{
		wcscpy(szCand, pCandBuf);
		iCandLen = wcslen(szCand);
		if (iCandLen == 0)
		{
			break;
		}
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"[%d] : %s ", i, szCand));
		pCandBuf += (iCandLen + 1);
	}
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("\r\n"));
	
	PRINTFUNCTIONINFO_END(GBSetCandBuffer);
}
SAMPLECODE_END(GBSetCandBuffer)


SAMPLECODE_BEGIN(GBGetCandBufferLen)
static void UT_GBGetCandBufferLen(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBI32 nBufferLen = 0;
	PRINTFUNCTIONINFO_BEGIN(GBGetCandBufferLen);
	retVal = GBGetCandBufferLen(pGBIS, &nBufferLen);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetCandBufferLen : buffer Len = %d\r\n", nBufferLen));
	PRINTFUNCTIONINFO_END(GBGetCandBufferLen);
}
SAMPLECODE_END(GBGetCandBufferLen)


SAMPLECODE_BEGIN(GBGetCandidate)
static void UT_GBGetCandidate(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBPWCHAR c_inputStr = L"6442662";
	PRINTFUNCTIONINFO_BEGIN(GBGetCandidate);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	SET_INPUT_STRING(pGBIS, c_inputStr);

	retVal = GBGetCandidate(pGBIS, 0, 10);
	PRINTLOOKUPINFOMATION(retVal);
	PRINT_CANDS(pGBIS);
	PRINTFUNCTIONINFO_END(GBGetCandidate);
}
SAMPLECODE_END(GBGetCandidate)


SAMPLECODE_BEGIN(GBGetCandidateEx)
static void UT_GBGetCandidateEx(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBPWCHAR c_inputStr = L"6442662";
	GBWCHAR szCandBuffer[256] = {0};
	GBU8 szInputLen[16] = {0};
	GBPWCHAR szCandArray[16] = {0};
	int i = 0;
	PRINTFUNCTIONINFO_BEGIN(GBGetCandidateEx);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	SET_INPUT_STRING(pGBIS, c_inputStr);

	retVal = GBGetCandidateEx(pGBIS, 0, szCandBuffer, sizeof(szCandBuffer), szInputLen, szCandArray, 10);
	PRINTLOOKUPINFOMATION(retVal);

	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("cand list : "));

	while (szCandArray[i])
	{
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"%s(%d) ", szCandArray[i], szInputLen[i]));
		i++;
	}
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("\r\n"));
	
	PRINTFUNCTIONINFO_END(GBGetCandidateEx);
}
SAMPLECODE_END(GBGetCandidateEx)


SAMPLECODE_BEGIN(GBGetCandidatesCount)
static void UT_GBGetCandidatesCount(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBPWCHAR c_inputStr = L"64426";
	GBINT nCandCount = 0;
	PRINTFUNCTIONINFO_BEGIN(GBGetCandidatesCount);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	SET_INPUT_STRING(pGBIS, c_inputStr);

// 	retVal = GBGetCandidate(pGBIS, 0, 10);
// 	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetCandidate : ret = %d\r\n", retVal));
// 	PRINT_CANDS(pGBIS);
	retVal = GBGetCandidatesCount(pGBIS, &nCandCount);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetCandidatesCount : cand count = %d\r\n", nCandCount));
	PRINTFUNCTIONINFO_END(GBGetCandidatesCount);
}
SAMPLECODE_END(GBGetCandidatesCount)


SAMPLECODE_BEGIN(GBGetCandidatePageCount)
static void UT_GBGetCandidatePageCount(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBPWCHAR c_inputStr = L"64426";
	GBINT nCandPageCount = 0;
	PRINTFUNCTIONINFO_BEGIN(GBGetCandidatePageCount);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	SET_INPUT_STRING(pGBIS, c_inputStr);

	retVal = GBGetCandidatePageCount(pGBIS, &nCandPageCount);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetCandidatePageCount : cand page count = %d\r\n", nCandPageCount));
	PRINTFUNCTIONINFO_END(GBGetCandidatePageCount);
}
SAMPLECODE_END(GBGetCandidatePageCount)


SAMPLECODE_BEGIN(GBGetCurrentCandidatePageIndex)
static void UT_GBGetCurrentCandidatePageIndex(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBPWCHAR c_inputStr = L"64426";
	GBINT nCurCandPageIndex = 0;
	PRINTFUNCTIONINFO_BEGIN(GBGetCurrentCandidatePageIndex);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	SET_INPUT_STRING(pGBIS, c_inputStr);

	retVal = GBNextPageCandidateEx(pGBIS, 7, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST
		, ("GBNextPageCandidateEx : startIndex=%d\r\n", 7));

	retVal = GBGetCurrentCandidatePageIndex(pGBIS, &nCurCandPageIndex);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST
		, ("GBGetCurrentCandidatePageIndex : current cand page index = %d\r\n", nCurCandPageIndex));

	PRINTFUNCTIONINFO_END(GBGetCurrentCandidatePageIndex);
}
SAMPLECODE_END(GBGetCurrentCandidatePageIndex)


SAMPLECODE_BEGIN(GBUpscreenChar)
static void UT_GBUpscreenChar(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
//	GBPWCHAR c_inputStr = L"64";
	PRINTFUNCTIONINFO_BEGIN(GBUpscreenChar);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
// 	SET_INPUT_STRING(pGBIS, c_inputStr);
// 
// 	retVal = GBNextPageCandidateEx(pGBIS, 0, 0);
// 	PRINT_CANDS(pGBIS);
	retVal = GBUpscreenChar(pGBIS, L'你');
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"up screen : %s\r\n", pGBIS->outputInfo.pUpScreenStr));
	PRINTFUNCTIONINFO_END(GBUpscreenChar);
}
SAMPLECODE_END(GBUpscreenChar)


SAMPLECODE_BEGIN(GBTransFormat)
static void UT_GBTransFormat(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBPWCHAR c_inputStr = L"4663";
	PRINTFUNCTIONINFO_BEGIN(GBTransFormat);
	SET_INPUT_MODE(pGBIS, GBL_English, 0, GBIM_Predictive);
	SET_INPUT_STRING(pGBIS, c_inputStr);

	retVal = GBNextPageCandidateEx(pGBIS, 0, 0);
	PRINT_CANDS(pGBIS);

	retVal = GBSetShiftCap(pGBIS, 0, 1);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBSetShiftCap : ret = %d, Shift=0, Cap=1\r\n", retVal));
	GBTransFormat(pGBIS, (GBPWCHAR)pGBIS->outputInfo.pCandidates[0]);
	PRINTLOOKUPINFOMATION(retVal);
	PRINT_CANDS(pGBIS);
	PRINTFUNCTIONINFO_END(GBTransFormat);
}
SAMPLECODE_END(GBTransFormat)


SAMPLECODE_BEGIN(GBUpscreenString)
static void UT_GBUpscreenString(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
//	GBPWCHAR c_inputStr = L"64426";
	PRINTFUNCTIONINFO_BEGIN(GBUpscreenString);

	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
//	SET_INPUT_STRING(pGBIS, c_inputStr);
// 	retVal = GBNextPageCandidateEx(pGBIS, 0, 0);
// 	PRINT_CANDS(pGBIS);
	retVal = GBUpscreenString(pGBIS, L"你好");
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"up screen : %s\r\n", pGBIS->outputInfo.pUpScreenStr));

	PRINTFUNCTIONINFO_END(GBUpscreenString);
}
SAMPLECODE_END(GBUpscreenString)


SAMPLECODE_BEGIN(GBAlpGetEmbeddedInterpunctionKey)
static void UT_GBAlpGetEmbeddedInterpunctionKey(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBCHAR cEmbeddedInterpunctionKey = 0;
	PRINTFUNCTIONINFO_BEGIN(GBAlpGetEmbeddedInterpunctionKey);
	SET_INPUT_MODE(pGBIS, GBL_English, 0, GBIM_Predictive);

	retVal = GBAlpGetEmbeddedInterpunctionKey(pGBIS, &cEmbeddedInterpunctionKey);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBAlpGetEmbeddedInterpunctionKey : key = %c\r\n", cEmbeddedInterpunctionKey));
	PRINTFUNCTIONINFO_END(GBAlpGetEmbeddedInterpunctionKey);
}
SAMPLECODE_END(GBAlpGetEmbeddedInterpunctionKey)


SAMPLECODE_BEGIN(GBChnControlChar)
static void UT_GBChnControlChar(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBWCHAR nPhraseInput = 0; 
	GBWCHAR nWildCard = 0;
	PRINTFUNCTIONINFO_BEGIN(GBChnControlChar);

	retVal = GBChnControlChar(pGBIS, &nPhraseInput, &nWildCard);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBChnControlChar : split=%c wildCard=%c\r\n", nPhraseInput, nWildCard));
	PRINTFUNCTIONINFO_END(GBChnControlChar);
}
SAMPLECODE_END(GBChnControlChar)


SAMPLECODE_BEGIN(GBInputResetNoHook)
static void UT_GBInputResetNoHook(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBU16 GB_StarSymbol[] = L".,/<>?;':\"[]{}~!@#$%^&*()_+|\\=-`";
	PRINTFUNCTIONINFO_BEGIN(GBInputResetNoHook);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);

	GBMMIRegisterInterpunctionKeyEx(pGBIS, GBKEY_AMB_SPECIAL_A, GB_StarSymbol, 0, GBCL_MULTITAP, 1, 8, GBIKO_Input_Status_Confirm_Candidate);
	GBMMIHandleKeyEvent(pGBIS, GBKEY_AMB_SPECIAL_A, 0);
	retVal = GBInputResetNoHook(pGBIS);
	PRINTLOOKUPINFOMATION(retVal);

	PRINTFUNCTIONINFO_END(GBInputResetNoHook);
}
SAMPLECODE_END(GBInputResetNoHook)


SAMPLECODE_BEGIN(GBSetCandType)
static void UT_GBSetCandType(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	PRINTFUNCTIONINFO_BEGIN(GBSetCandType);
	SET_INPUT_MODE(pGBIS, GBL_English, 0, GBIM_Predictive);
	retVal = GBSetCandType(pGBIS, GBCT_MultiTap_Cap);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBSetCandType ,%s, ret = %d\r\n", "GBCT_MultiTap_Cap", retVal));
	retVal = GBMMIHandleKeyEvent(pGBIS, L'2', 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIHandleKeyEvent ,%c, ret = %d\r\n", '2', retVal));
	PRINT_CANDS(pGBIS);
	retVal = GBMMIReset(pGBIS);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIReset ,ret = %d\r\n", retVal));
	retVal = GBSetCandType(pGBIS, GBCT_MultiTap_Lower);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBSetCandType ,%s, ret = %d\r\n", "GBCT_MultiTap_Lower", retVal));
	retVal = GBMMIHandleKeyEvent(pGBIS, L'2', 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIHandleKeyEvent ,%c, ret = %d\r\n", '2', retVal));
	PRINT_CANDS(pGBIS);
	PRINTFUNCTIONINFO_END(GBSetCandType);
}
SAMPLECODE_END(GBSetCandType)


SAMPLECODE_BEGIN(GBUpdateOutputInfo)
static void UT_GBUpdateOutputInfo(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBWCHAR c_inputStr[] = L"9426";
	PRINTFUNCTIONINFO_BEGIN(GBUpdateOutputInfo);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	SET_INPUT_STRING(pGBIS, c_inputStr);
	retVal = GBNextPageCandidate(pGBIS, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBNextPageCandidate ret = %d\r\n", retVal));
	PRINT_SYLLABLE(pGBIS);
	retVal = GBUpdateOutputInfo(pGBIS);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBUpdateOutputInfo ret = %d\r\n", retVal));
	PRINT_SYLLABLE(pGBIS);

	PRINTFUNCTIONINFO_END(GBUpdateOutputInfo);
}
SAMPLECODE_END(GBUpdateOutputInfo)


SAMPLECODE_BEGIN(GBGetFullInputString)
static void UT_GBGetFullInputString(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBLPCWCHAR pFullInputString = NULL;
	GBWCHAR c_input_string[] = L"23456789";
	PRINTFUNCTIONINFO_BEGIN(GBGetFullInputString);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	GBSetEngineOption(pGBIS, GB_ENGINE_FUNCTION, GBFO_Chn_Display_Input_Key_Sequence, 1);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBSetEngineOption, GBFO_Chn_Display_Input_Key_Sequence, 1\r\n"));
	retVal = GBMMIHandleKeyEvent(pGBIS, GBEVENT_SET_INPUT_STRING, (GBU32)c_input_string);
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBMMIHandleKeyEvent->GBEVENT_SET_INPUT_STRING, %s, ret = %d\r\n", c_input_string, retVal));
	retVal = GBMMIHandleKeyEvent(pGBIS, GBKEY_OK, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIHandleKeyEvent, GBKEY_OK, ret = %d\r\n", retVal));
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"pGBIS->pAuxInfo->pOutputString = %s\r\n", pGBIS->pAuxInfo->pOutputString));
	retVal = GBGetFullInputString(pGBIS, &pFullInputString);
	if (pFullInputString)
	{
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"pFullInputString = %s\r\n", pFullInputString));
	}
	PRINTLOOKUPINFOMATION(retVal);
	PRINTFUNCTIONINFO_END(GBGetFullInputString);
}
SAMPLECODE_END(GBGetFullInputString)

//#MDB 细胞数据库（MDB）

SAMPLECODE_BEGIN(GBMDBInit)
static void UT_GBMDBInit(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	int i = 0;
	char* pLDBpath = "..\\..\\Engine\\data\\gb_sc_ldb.ebd";
	char* pMDBpath = "..\\..\\Engine\\data\\gb_sc_mdb.mdb";
	GBLDB ldb;
	GBMDB* pMDB = GetEngineMDBDataInfo();
	GBU16* pMDBCount = GetEngineMDBDataCount();
	GBU32* pMDBBuffer = GetEngineMDBBuffer();
	GBU32 nMDBBufferSize = GetEngineMDBBufferSize();
	GBLANG nLang;
	GBSUBLANG nSubLang;
	GBU32 fileSize;
	char header_data[256];
	FILE * fp = NULL;
	PRINTFUNCTIONINFO_BEGIN(GBMDBInit);
	//加载主数据
	GBIM_LoadLDB_Ex(pGBIS, pLDBpath, &ldb);
	GBTerminate(pGBIS);
	GBInitialize(pGBIS, &ldb, 1);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	//加载方言数据
	fp = fopen(pMDBpath, "rb");
	if(!fp)
	{
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("file %s open error!\r\n", pMDBpath));
		return;
	}
	//	int id;
	if(fread(header_data, sizeof(header_data), 1, fp) != 1)
	{
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("file %s open error!\r\n", pMDBpath));
		return;
	}
	if(GBGetDataLanguage(header_data, (GBLANG*)&nLang, (GBSUBLANG*)&nSubLang, &fileSize) == GBOK)
	{
		pMDB[0].dbBaseInfo.nLang = nLang;
		pMDB[0].dbBaseInfo.nSubLang = nSubLang;
		pMDB[0].dbBaseInfo.pData = (const unsigned long*)fp;
		pMDB[0].nType = dtFileData;
		pMDB[0].nFileSize = fileSize;
		pMDB[0].isAttach = FALSE;
		//(*pMDBCount)++;
		*pMDBCount = 1;
	}
	retVal = GBMDBInit(pGBIS, pMDBBuffer, nMDBBufferSize);
	PRINTLOOKUPINFOMATION(retVal);
	PRINTFUNCTIONINFO_END(GBMDBInit);
}
SAMPLECODE_END(GBMDBInit)


SAMPLECODE_BEGIN(GBMDBAttach)
static void UT_GBMDBAttach(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	int i = 0;
	char* pLDBpath = "..\\..\\Engine\\data\\gb_sc_ldb.ebd";
	char* pMDBpath = "..\\..\\Engine\\data\\gb_sc_mdb.mdb";
	GBLDB ldb;
	GBMDB* pMDB = GetEngineMDBDataInfo();
	GBU16* pMDBCount = GetEngineMDBDataCount();
	GBU32* pMDBBuffer = GetEngineMDBBuffer();
	GBU32 nMDBBufferSize = GetEngineMDBBufferSize();
	GBLANG nLang;
	GBSUBLANG nSubLang;
	GBU32 fileSize;
	char header_data[256];
	FILE * fp = NULL;

	PRINTFUNCTIONINFO_BEGIN(GBMDBAttach);
	//加载主数据
	GBIM_LoadLDB_Ex(pGBIS, pLDBpath, &ldb);
	GBTerminate(pGBIS);
	GBInitialize(pGBIS, &ldb, 1);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	//加载方言数据
	fp = fopen(pMDBpath, "rb");
	if(!fp)
	{
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("file %s open error!\r\n", pMDBpath));
		return;
	}
	//	int id;
	if(fread(header_data, sizeof(header_data), 1, fp) != 1)
	{
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("file %s read error!\r\n", pMDBpath));
		return;
	}
	if(GBGetDataLanguage(header_data, (GBLANG*)&nLang, (GBSUBLANG*)&nSubLang, &fileSize) == GBOK)
	{
		pMDB[0].dbBaseInfo.nLang = nLang;
		pMDB[0].dbBaseInfo.nSubLang = nSubLang;
		pMDB[0].nType = dtFileDataInMemory;
		pMDB[0].isAttach = FALSE;
		//(*pMDBCount)++;
		
		pMDB[0].dbBaseInfo.pData = (GBLPCVOID)malloc(fileSize);
		fseek(fp, 0, SEEK_SET);
		if(fread((GBU8*)pMDB[0].dbBaseInfo.pData, 1, fileSize, fp) != fileSize)
		{
			fclose(fp);
			PT_PrintLogInfo(e_GBLOG_UNITTEST, ("file %s read error!\r\n", pMDBpath));
			return ;
		}
		pMDB[0].nFileSize = fileSize;
		*pMDBCount = 1;
		fclose(fp);
	}
	retVal = GBMDBAttach(pGBIS,
		pMDB[0].dbBaseInfo.pData, 
		pMDB[0].dbBaseInfo.nLang,
		pMDB[0].nFileSize,
		&pMDB[0].nId);
	PRINTLOOKUPINFOMATION(retVal);

	if (pMDB[0].dbBaseInfo.pData)
	{
		free(pMDB[0].dbBaseInfo.pData);
		pMDB[0].dbBaseInfo.pData = NULL;
	}
	PRINTFUNCTIONINFO_END(GBMDBAttach);
}
SAMPLECODE_END(GBMDBAttach)


SAMPLECODE_BEGIN(GBMDBAttachFile)
static void UT_GBMDBAttachFile(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	int i = 0;
	char* pLDBpath = "..\\..\\Engine\\data\\gb_sc_ldb.ebd";
	char* pMDBpath = "..\\..\\Engine\\data\\gb_sc_mdb.mdb";
	GBLDB ldb;
	GBMDB* pMDB = GetEngineMDBDataInfo();
	GBU16* pMDBCount = GetEngineMDBDataCount();
	GBU32* pMDBBuffer = GetEngineMDBBuffer();
	GBU32 nMDBBufferSize = GetEngineMDBBufferSize();
	GBLANG nLang;
	GBSUBLANG nSubLang;
	GBU32 fileSize;
	char header_data[256];
	FILE * fp = NULL;

	PRINTFUNCTIONINFO_BEGIN(GBMDBAttachFile);
	//加载主数据
	GBIM_LoadLDB_Ex(pGBIS, pLDBpath, &ldb);
	GBTerminate(pGBIS);
	GBInitialize(pGBIS, &ldb, 1);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	//加载方言数据
	fp = fopen(pMDBpath, "rb");
	if(!fp)
	{
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("file %s open error!\r\n", pMDBpath));
		return;
	}
	//	int id;
	if(fread(header_data, sizeof(header_data), 1, fp) != 1)
	{
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("file %s open error!\r\n", pMDBpath));
		return;
	}
	if(GBGetDataLanguage(header_data, (GBLANG*)&nLang, (GBSUBLANG*)&nSubLang, &fileSize) == GBOK)
	{
		pMDB[0].dbBaseInfo.nLang = nLang;
		pMDB[0].dbBaseInfo.nSubLang = nSubLang;
		pMDB[0].dbBaseInfo.pData = (const unsigned long*)fp;
		pMDB[0].nType = dtFileData;
		pMDB[0].nFileSize = fileSize;
		pMDB[0].isAttach = FALSE;
		//(*pMDBCount)++;
		*pMDBCount = 1;
	}
	retVal = GBMDBInit(pGBIS, pMDBBuffer, nMDBBufferSize);
	retVal = GBMDBAttachFile(pGBIS,
		(GBLPVOID)pMDB[0].dbBaseInfo.pData, 
		pMDB[0].dbBaseInfo.nLang,
		(fpGBMDBReadData_t)fread,
		(fpGBMDBFileSeek_t)fseek,
		&pMDB[0].nId);
	PRINTLOOKUPINFOMATION(retVal);

	SET_INPUT_MODE(pGBIS, pMDB[0].dbBaseInfo.nLang, 0, GBIM_Qwerty_Pinyin);
	SET_INPUT_STRING(pGBIS, L"zhaok");
	GBNextPageCandidate(pGBIS, 0);
	for (i = 0; i < pGBIS->outputInfo.nCandNum; i++)
	{
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"[%d] : %s ", i, pGBIS->outputInfo.pCandidates[i]));
	}
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"\r\n"));

	PRINTFUNCTIONINFO_END(GBMDBAttachFile);
}
SAMPLECODE_END(GBMDBAttachFile)


SAMPLECODE_BEGIN(GBMDBDetach)
static void UT_GBMDBDetach(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBINT nMDBID = 0;
	GBU16 * pMDBCount = GetEngineMDBDataCount();
	GBMDB * pMDBInfo = GetEngineMDBDataInfo();
	PRINTFUNCTIONINFO_BEGIN(GBMDBDetach);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Qwerty_Pinyin);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBIM_LoadMDB\r\n"));
	GBIM_LoadMDB();
	nMDBID = pMDBInfo[0].nId;
	retVal = GBMDBDetach(pGBIS, nMDBID);
	PRINTLOOKUPINFOMATION(retVal);

	PRINTFUNCTIONINFO_END(GBMDBDetach);
}
SAMPLECODE_END(GBMDBDetach)


SAMPLECODE_BEGIN(GBMDBCheckPhrase)
static void UT_GBMDBCheckPhrase(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBINT nMDBID;
	GBU16 * pMDBCount = GetEngineMDBDataCount();
	GBMDB * pMDBInfo = GetEngineMDBDataInfo();
	PRINTFUNCTIONINFO_BEGIN(GBMDBCheckPhrase);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Qwerty_Pinyin);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBIM_LoadMDB\r\n"));
	GBIM_LoadMDB();
	nMDBID = pMDBInfo[0].nId;
	retVal = GBMDBCheckPhrase(pGBIS, nMDBID, L"你为什么");
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMDBCheckPhrase %s, ret = %d\r\n", "你为什么", retVal));
	retVal = GBMDBCheckPhrase(pGBIS, nMDBID, L"爱上男主播");
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMDBCheckPhrase %s, ret = %d\r\n", "爱上男主播", retVal));
	retVal = GBMDBCheckPhrase(pGBIS, nMDBID, L"广东国笔");
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMDBCheckPhrase %s, ret = %d\r\n", "广东国笔", retVal));
	PRINTFUNCTIONINFO_END(GBMDBCheckPhrase);
}
SAMPLECODE_END(GBMDBCheckPhrase)


SAMPLECODE_BEGIN(GBMDBAddPhrase)
static void UT_GBMDBAddPhrase(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	int i = 0;
	char* pLDBpath = "..\\..\\Engine\\data\\gb_sc_ldb.ebd";
	char* pMDBpath = "..\\..\\Engine\\data\\gb_sc_mdb.mdb";
	GBLDB ldb;
	GBMDB* pMDB = GetEngineMDBDataInfo();
	GBU16* pMDBCount = GetEngineMDBDataCount();
	GBU32* pMDBBuffer = GetEngineMDBBuffer();
	GBU32 nMDBBufferSize = GetEngineMDBBufferSize();
	GBLANG nLang;
	GBSUBLANG nSubLang;
	GBU32 fileSize;
	char header_data[256];
	FILE * fp = NULL;
	PRINTFUNCTIONINFO_BEGIN(GBMDBAddPhrase);
	//加载主数据
	GBIM_LoadLDB_Ex(pGBIS, pLDBpath, &ldb);
	GBTerminate(pGBIS);
	GBInitialize(pGBIS, &ldb, 1);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	//加载方言数据
	fp = fopen(pMDBpath, "rb");
	if(!fp)
	{
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("file %s open error!\r\n", pMDBpath));
		return;
	}
	//	int id;
	if(fread(header_data, sizeof(header_data), 1, fp) != 1)
	{
		PT_PrintLogInfo(e_GBLOG_UNITTEST, ("file %s open error!\r\n", pMDBpath));
		return;
	}
	if(GBGetDataLanguage(header_data, (GBLANG*)&nLang, (GBSUBLANG*)&nSubLang, &fileSize) == GBOK)
	{
		pMDB[0].dbBaseInfo.nLang = nLang;
		pMDB[0].dbBaseInfo.nSubLang = nSubLang;
		pMDB[0].dbBaseInfo.pData = (const unsigned long*)fp;
		pMDB[0].nType = dtFileData;
		pMDB[0].nFileSize = fileSize;
		pMDB[0].isAttach = FALSE;
		//(*pMDBCount)++;
		*pMDBCount = 1;
	}
	retVal = GBMDBInit(pGBIS, pMDBBuffer, nMDBBufferSize);
	retVal = GBMDBAttachFile(pGBIS,
		(GBLPVOID)pMDB[0].dbBaseInfo.pData, 
		pMDB[0].dbBaseInfo.nLang,
		(fpGBMDBReadData_t)fread,
		(fpGBMDBFileSeek_t)fseek,
		&pMDB[0].nId);

	SET_INPUT_MODE(pGBIS, pMDB[0].dbBaseInfo.nLang, 0, GBIM_Qwerty_Pinyin);
	retVal = GBMDBAddPhrase(pGBIS, fp, (fpGBMDBFileSeek_t)fseek, (fpGBMDBWriteData_t)fwrite, (fpGBMDBReadData_t)fread, L"国笔", L"guobi");
	PRINTLOOKUPINFOMATION(retVal);
	SET_INPUT_STRING(pGBIS, L"guob");
	GBNextPageCandidate(pGBIS, 0);
	for (i = 0; i < pGBIS->outputInfo.nCandNum; i++)
	{
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"[%d] : %s ", i, pGBIS->outputInfo.pCandidates[i]));
	}
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"\r\n"));

	PRINTFUNCTIONINFO_END(GBMDBAddPhrase);
}
SAMPLECODE_END(GBMDBAddPhrase)

//#UDB 用户自造词函数

SAMPLECODE_BEGIN(GBAddUsedWord)
static void UT_GBAddUsedWord(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBU32* pCurUDBID;
	int i = 0;
	GBPWCHAR szAddBuf[] = {L"国笔", L"国笔科技"};
	PRINTFUNCTIONINFO_BEGIN(GBAddUsedWord);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	GBIM_LoadUDB();
	pCurUDBID = GetEngineCurUDBID();
	for (i = 0; i < ARRAY_DIM(szAddBuf); i++)
	{
		retVal = GBUDBAddPhrase(pGBIS, szAddBuf[i], NULL);
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBUDBAddPhrase : %s ret=%d\r\n", szAddBuf[i], retVal));
	}
	SET_INPUT_STRING(pGBIS, L"48624");
	GBNextPageCandidate(pGBIS, 0);
	for (i = 0; i < pGBIS->outputInfo.nCandNum; i++)
	{
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"[%d] : %s ", i, pGBIS->outputInfo.pCandidates[i]));
	}
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"\r\n"));
	retVal = GBAddUsedWord(pGBIS, *pCurUDBID, L"国笔");
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBAddUsedWord : %s, ret = %d\r\n", L"国笔", retVal));
	GBReset(pGBIS);
	SET_INPUT_STRING(pGBIS, L"48624");
	GBNextPageCandidate(pGBIS, 0);
	for (i = 0; i < pGBIS->outputInfo.nCandNum; i++)
	{
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"[%d] : %s ", i, pGBIS->outputInfo.pCandidates[i]));
	}
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"\r\n"));	

	for (i = 0; i < ARRAY_DIM(szAddBuf); i++)
	{
		retVal = GBUDBDeletePhrase(pGBIS, szAddBuf[i]);
	}
	PRINTFUNCTIONINFO_END(GBAddUsedWord);
}
SAMPLECODE_END(GBAddUsedWord)


SAMPLECODE_BEGIN(GBUDBAttach)
static void UT_GBUDBAttach(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBU32* pUDBBuffer = GetEngineUDBBuffer();
	GBU32 nUDBBufferSize = GetEngineUDBBufferSize();
	GBU32 nUDBID = 0;
	GBU32* pCurUDBID;
	PRINTFUNCTIONINFO_BEGIN(GBUDBAttach);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	GBIM_LoadUDB();
	retVal = GBUDBAttach(pGBIS, pUDBBuffer, nUDBBufferSize, pGBIS->nLang, pGBIS->nSubLang, &nUDBID);
	PRINTLOOKUPINFOMATION(retVal);
	pCurUDBID = GetEngineCurUDBID();
	retVal = GBUDBDetach(pGBIS, *pCurUDBID);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBUDBDetach UDBID=%d, ret=%d\r\n", *pCurUDBID, retVal));
	retVal = GBUDBAttach(pGBIS, pUDBBuffer, nUDBBufferSize, pGBIS->nLang, pGBIS->nSubLang, &nUDBID);
	PRINTLOOKUPINFOMATION(retVal);
	PRINTFUNCTIONINFO_END(GBUDBAttach);
}
SAMPLECODE_END(GBUDBAttach)


SAMPLECODE_BEGIN(GBChnUDBAttach)
static void UT_GBChnUDBAttach(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBU32* pUDBBuffer = GetEngineUDBBuffer();
	GBU32 nUDBBufferSize = GetEngineUDBBufferSize();
	GBU32* pupContentBuffer = GetEngineUpContentBuffer();
	GBU32 nUpContentBufferSize = GetEngineUpContentBufferSize();
	GBU32 nUDBID = 0;
	GBU32* pCurUDBID;
	PRINTFUNCTIONINFO_BEGIN(GBChnUDBAttach);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	GBIM_LoadUDB();
	retVal = GBChnUDBAttach(pGBIS, pUDBBuffer, nUDBBufferSize, 
		pupContentBuffer, nUpContentBufferSize, pGBIS->nLang, pGBIS->nSubLang, &nUDBID);
	PRINTLOOKUPINFOMATION(retVal);
	pCurUDBID = GetEngineCurUDBID();
	retVal = GBChnUDBDetach(pGBIS, *pCurUDBID);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBChnUDBDetach UDBID=%d, ret=%d\r\n", *pCurUDBID, retVal));
	retVal = GBChnUDBAttach(pGBIS, pUDBBuffer, nUDBBufferSize, 
		pupContentBuffer, nUpContentBufferSize, pGBIS->nLang, pGBIS->nSubLang, &nUDBID);
	PRINTLOOKUPINFOMATION(retVal);
	PRINTFUNCTIONINFO_END(GBChnUDBAttach);
}
SAMPLECODE_END(GBChnUDBAttach)


SAMPLECODE_BEGIN(GBChnUDBDetach)
static void UT_GBChnUDBDetach(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBU32* pUDBID;
	PRINTFUNCTIONINFO_BEGIN(GBChnUDBDetach);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	GBIM_LoadUDB();
	pUDBID = GetEngineCurUDBID();
	retVal = GBChnUDBDetach(pGBIS, *pUDBID);
	PRINTLOOKUPINFOMATION(retVal);
	PRINTFUNCTIONINFO_END(GBChnUDBDetach);
}
SAMPLECODE_END(GBChnUDBDetach)


SAMPLECODE_BEGIN(GBChnUDBDataReset)
static void UT_GBChnUDBDataReset(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	PRINTFUNCTIONINFO_BEGIN(GBChnUDBDataReset);
	PRINTFUNCTIONINFO_BEGIN(GBChnUDBSetUpdateParam);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	GBIM_LoadUDB();
	retVal = GBChnUDBDataReset(pGBIS);
	PRINTLOOKUPINFOMATION(retVal);
	PRINTFUNCTIONINFO_END(GBChnUDBDataReset);
}
SAMPLECODE_END(GBChnUDBDataReset)


SAMPLECODE_BEGIN(GBChnUDBSetUpdateParam)
static void UT_GBChnUDBSetUpdateParam(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	int i = 0;
	GBWCHAR szBuffer[64] = {0};
	GBU32* pUDBID;
	GBPWCHAR szAddBuf[] = {L"国笔", L"国笔科技"};
	PRINTFUNCTIONINFO_BEGIN(GBChnUDBSetUpdateParam);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	GBIM_LoadUDB();
	 pUDBID = GetEngineCurUDBID();
	retVal = GBChnUDBSetUpdateParam(pGBIS, *pUDBID, 1, GBUDBUpdateFun, GBUpContentUpdateFun, (GBLPVOID)pGBIS);
	PRINTLOOKUPINFOMATION(retVal);
	for (i = 0; i < ARRAY_DIM(szAddBuf); i++)
	{
		retVal = GBUDBAddPhrase(pGBIS, szAddBuf[i], NULL);
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBUDBAddPhrase : %s ret=%d\r\n", szAddBuf[i], retVal));
	}
	GBMMIHandleKeyEvent(pGBIS, GBKEY_2, 0);
	GBMMIHandleKeyEvent(pGBIS, GBKEY_OK, 0);
	GBMMIHandleKeyEvent(pGBIS, GBKEY_OK, 0);

	for (i = 0; i < ARRAY_DIM(szAddBuf); i++)
	{
		retVal = GBUDBDeletePhrase(pGBIS, szAddBuf[i]);
	}
	PRINTFUNCTIONINFO_END(GBChnUDBSetUpdateParam);
}
SAMPLECODE_END(GBChnUDBSetUpdateParam)


SAMPLECODE_BEGIN(GBUDBSetUpdateParam)
static void UT_GBUDBSetUpdateParam(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	int i = 0;
	GBU32* pUDBID = GetEngineCurUDBID();
	GBPWCHAR szAddBuf[] = {L"国笔", L"国笔科技"};
	PRINTFUNCTIONINFO_BEGIN(GBUDBSetUpdateParam);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	GBIM_LoadUDB();
	retVal = GBUDBSetUpdateParam(pGBIS, *pUDBID, 1, GBUDBUpdateFun, (GBLPVOID)pGBIS);
	PRINTLOOKUPINFOMATION(retVal);
	for (i = 0; i < ARRAY_DIM(szAddBuf); i++)
	{
		retVal = GBUDBAddPhrase(pGBIS, szAddBuf[i], NULL);
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBUDBAddPhrase : %s ret=%d\r\n", szAddBuf[i], retVal));
	}
	PRINTFUNCTIONINFO_END(GBUDBSetUpdateParam);
}
SAMPLECODE_END(GBUDBSetUpdateParam)


SAMPLECODE_BEGIN(GBUDBGetModifiedCount)
static void UT_GBUDBGetModifiedCount(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	int i = 0;
	GBU32* pUDBID = GetEngineCurUDBID();
	GBU32 nModifiedCount = 0;
	GBPWCHAR szAddBuf[] = {L"国笔", L"国笔科技"};
	PRINTFUNCTIONINFO_BEGIN(GBUDBGetModifiedCount);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	GBIM_LoadUDB();
	for (i = 0; i < ARRAY_DIM(szAddBuf); i++)
	{
		retVal = GBUDBAddPhrase(pGBIS, szAddBuf[i], NULL);
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBUDBAddPhrase : %s ret=%d\r\n", szAddBuf[i], retVal));
	}
	retVal = GBUDBGetModifiedCount(pGBIS, *pUDBID, &nModifiedCount);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBUDBGetModifiedCount modify %d, ret=%d\r\n", nModifiedCount, retVal));

	for (i = 0; i < ARRAY_DIM(szAddBuf); i++)
	{
		retVal = GBUDBDeletePhrase(pGBIS, szAddBuf[i]);
	}
	PRINTFUNCTIONINFO_END(GBUDBGetModifiedCount);
}
SAMPLECODE_END(GBUDBGetModifiedCount)


SAMPLECODE_BEGIN(GBUDBDataReset)
static void UT_GBUDBDataReset(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	PRINTFUNCTIONINFO_BEGIN(GBUDBDataReset);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	GBIM_LoadUDB();
	retVal = GBUDBDataReset(pGBIS);
	PRINTLOOKUPINFOMATION(retVal);		
	PRINTFUNCTIONINFO_END(GBUDBDataReset);
}
SAMPLECODE_END(GBUDBDataReset)


SAMPLECODE_BEGIN(GBUDBDetach)
static void UT_GBUDBDetach(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBU32* pUDBID = GetEngineCurUDBID();
	PRINTFUNCTIONINFO_BEGIN(GBUDBDetach);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	GBIM_LoadUDB();
	pUDBID = GetEngineCurUDBID();
	retVal = GBUDBDetach(pGBIS, *pUDBID);
	PRINTLOOKUPINFOMATION(retVal);		
	PRINTFUNCTIONINFO_END(GBUDBDetach);
}
SAMPLECODE_END(GBUDBDetach)


SAMPLECODE_BEGIN(GBUDBAddPhrase)
static void UT_GBUDBAddPhrase(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	int i = 0;
	GBPWCHAR szAddBuf[] = {L"国笔", L"国笔科技"};
	PRINTFUNCTIONINFO_BEGIN(GBUDBAddPhrase);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	GBIM_LoadUDB();
	for (i = 0; i < ARRAY_DIM(szAddBuf); i++)
	{
		retVal = GBUDBAddPhrase(pGBIS, szAddBuf[i], NULL);
		PRINTLOOKUPINFOMATION(retVal);		
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBUDBAddPhrase : %s ret=%d\r\n", szAddBuf[i], retVal));
	}	
	for (i = 0; i < ARRAY_DIM(szAddBuf); i++)
	{
		retVal = GBUDBDeletePhrase(pGBIS, szAddBuf[i]);
	}
	PRINTFUNCTIONINFO_END(GBUDBAddPhrase);
}
SAMPLECODE_END(GBUDBAddPhrase)


SAMPLECODE_BEGIN(GBUDBDeletePhrase)
static void UT_GBUDBDeletePhrase(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBWCHAR szBuffer[64];
	int i = 0;
	GBPWCHAR szAddBuf[] = {L"国笔", L"国笔科技"};
	PRINTFUNCTIONINFO_BEGIN(GBUDBDeletePhrase);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	GBIM_LoadUDB();
	for (i = 0; i < ARRAY_DIM(szAddBuf); i++)
	{
		retVal = GBUDBAddPhrase(pGBIS, szAddBuf[i], NULL);
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBUDBAddPhrase : %s ret=%d\r\n", szAddBuf[i], retVal));
	}
	retVal = GBUDBDeletePhrase(pGBIS, szAddBuf[0]);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBUDBDeletePhrase : %s ret=%d\r\n", szAddBuf[0], retVal));
	i = 0;
	while(TRUE)
	{
		retVal = GBUDBGetNextPhrase(pGBIS, &i, szBuffer, sizeof(szBuffer));
		if (retVal == GB_API_UDB_NO_MORE_PHRASE)
		{
			break;
		}
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBUDBGetNextPhrase : %s ret=%d\r\n", szBuffer, retVal));
	}
	for (i = 0; i < ARRAY_DIM(szAddBuf); i++)
	{
		retVal = GBUDBDeletePhrase(pGBIS, szAddBuf[i]);
	}
	PRINTFUNCTIONINFO_END(GBUDBDeletePhrase);
}
SAMPLECODE_END(GBUDBDeletePhrase)


SAMPLECODE_BEGIN(GBUDBGetNextPhrase)
static void UT_GBUDBGetNextPhrase(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBUINT32 nParamItem = 0;
	GBWCHAR szBuffer[64];
	GBPWCHAR szAddBuf[] = {L"国笔", L"国笔科技"};
	int i = 0;
	
	PRINTFUNCTIONINFO_BEGIN(GBUDBGetNextPhrase);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	GBIM_LoadUDB();
	for (i = 0; i < ARRAY_DIM(szAddBuf); i++)
	{
		retVal = GBUDBAddPhrase(pGBIS, szAddBuf[i], NULL);
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBUDBAddPhrase : %s ret=%d\r\n", szAddBuf[i], retVal));
	}
	i = 0;
	while(TRUE)
	{
		retVal = GBUDBGetNextPhrase(pGBIS, &i, szBuffer, sizeof(szBuffer));
		PRINTLOOKUPINFOMATION(retVal);		
		if (retVal == GB_API_UDB_NO_MORE_PHRASE)
		{
			break;
		}
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBUDBGetNextPhrase : %s ret=%d\r\n", szBuffer, retVal));
	}
	for (i = 0; i < ARRAY_DIM(szAddBuf); i++)
	{
		retVal = GBUDBDeletePhrase(pGBIS, szAddBuf[i]);
	}
	PRINTFUNCTIONINFO_END(GBUDBGetNextPhrase);
}
SAMPLECODE_END(GBUDBGetNextPhrase)

//#Auxiliary	辅助API

SAMPLECODE_BEGIN(GBIsInDatabase)
static void UT_GBIsInDatabase(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBWCHAR* pPhrase1 = L"你好";
	GBWCHAR* pPhrase2 = L"国笔";
	PRINTFUNCTIONINFO_BEGIN(GBIsInDatabase);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	GBIM_LoadUDB();
	retVal = GBIsInDatabase(pGBIS, pPhrase1);
	PRINTLOOKUPINFOMATION(retVal);
	retVal = GBIsInDatabase(pGBIS, pPhrase2);
	PRINTLOOKUPINFOMATION(retVal);
	PRINTFUNCTIONINFO_END(GBIsInDatabase);
}
SAMPLECODE_END(GBIsInDatabase)


SAMPLECODE_BEGIN(GBGetLastError)
static void UT_GBGetLastError(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	PRINTFUNCTIONINFO_BEGIN(GBGetLastError);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	retVal =GBMMIHandleKeyEvent(pGBIS, GBKEY_2, 0);
	retVal = GBGetLastError(pGBIS);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetLastError : 0x%x\r\n", retVal));

	PRINTFUNCTIONINFO_END(GBGetLastError);
}
SAMPLECODE_END(GBGetLastError)


SAMPLECODE_BEGIN(GBSetLastError)
static void UT_GBSetLastError(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	PRINTFUNCTIONINFO_BEGIN(GBSetLastError);
	retVal = GBAttachLogRecorder(pGBIS, LogRecorder, NULL);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBAttachLogRecorder : ret=%d\r\n", retVal));
	retVal = GBSetLastError(pGBIS, -0x9000);
	PRINTLOOKUPINFOMATION(retVal);
	retVal = GBGetLastError(pGBIS);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetLastError : 0x%x\r\n", retVal));
	PRINTFUNCTIONINFO_END(GBSetLastError);
}
SAMPLECODE_END(GBSetLastError)


SAMPLECODE_BEGIN(GBSetLastErrorEx)
static void UT_GBSetLastErrorEx(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	PRINTFUNCTIONINFO_BEGIN(GBSetLastErrorEx);
	retVal = GBAttachLogRecorder(pGBIS, LogRecorder, NULL);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBAttachLogRecorder : ret=%d\r\n", retVal));
	retVal = GBSetLastErrorEx(pGBIS, __FILE__, __LINE__, "测试设置错误值", -0x9000);
	PRINTLOOKUPINFOMATION(retVal);
	retVal = GBGetLastError(pGBIS);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetLastError : 0x%x\r\n", retVal));
	PRINTFUNCTIONINFO_END(GBSetLastErrorEx);
}
SAMPLECODE_END(GBSetLastErrorEx)


SAMPLECODE_BEGIN(GBAttachLogRecorder)
static void UT_GBAttachLogRecorder(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	PRINTFUNCTIONINFO_BEGIN(GBAttachLogRecorder);
	retVal = GBAttachLogRecorder(pGBIS, LogRecorder, NULL);
	PRINTLOOKUPINFOMATION(retVal);

	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	retVal =GBMMIHandleKeyEvent(pGBIS, GBKEY_2, 0);
	PRINTFUNCTIONINFO_END(GBAttachLogRecorder);
}
SAMPLECODE_END(GBAttachLogRecorder)


SAMPLECODE_BEGIN(GBGetDataLanguage)
// 从国笔引擎数据获取语言信息
static void UT_GBGetDataLanguage(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBLDB * pLDBData = GetEngineLDBDataInfo();
	GBU16 * pLDBCount = GetEngineLDBDataCount();
	GBLANG nLang;
	GBLANG nSubLang;
	GBU32 dataSize;
	GBU16 index;

	PRINTFUNCTIONINFO_BEGIN(GBGetDataLanguage);
	// 从国笔数据里获取语言信息
	for(index = 0; index < *pLDBCount; index++)
	{
		retVal = GBGetDataLanguage(pLDBData[index].pData, &nLang, &nSubLang, &dataSize);
		PRINTLOOKUPINFOMATION(retVal);
		if(retVal != GBOK)
		{
			PT_PrintModuleLogInfo(e_GBLOG_UNITTEST, ("Failed to get %d data language.\r\n", index));
			exit(1);
		}
		PT_PrintModuleLogInfo(e_GBLOG_UNITTEST, ("Success to get %d data language.\r\n", index));
		PT_PrintModuleLogInfo(e_GBLOG_UNITTEST, ("nLang = %d nSubLang = %d dataSize = %d.\r\n", nLang, nSubLang, dataSize));
	}
	PRINTFUNCTIONINFO_END(GBGetDataLanguage);
}
SAMPLECODE_END(GBGetDataLanguage)

//#GBMMI	GBMMI函数

SAMPLECODE_BEGIN(GBMMIHandleKeyEvent)
static void UT_GBMMIHandleKeyEvent(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	PRINTFUNCTIONINFO_BEGIN(GBMMIHandleKeyEvent);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	retVal =GBMMIHandleKeyEvent(pGBIS, GBKEY_2, 0);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIHandleKeyEvent GBKEY_2, ret=%d\r\n", retVal));
	PRINTFUNCTIONINFO_END(GBMMIHandleKeyEvent);
}
SAMPLECODE_END(GBMMIHandleKeyEvent)


SAMPLECODE_BEGIN(GBMMISetCandRowCount)
static void UT_GBMMISetCandRowCount(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	GBINT nCandRowCount = 3;
	PRINTFUNCTIONINFO_BEGIN(GBMMISetCandRowCount);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMISetCandRowCount : GBCS_INPUT, row count:%d\r\n", nCandRowCount));
	retVal = GBMMISetCandRowCount(pGBIS, GBCS_INPUT, nCandRowCount);
	PRINTLOOKUPINFOMATION(retVal);
	retVal =GBMMIHandleKeyEvent(pGBIS, GBKEY_2, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIHandleKeyEvent GBKEY_2, ret=%d\r\n", retVal));
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("cur cand row=%d\r\n", pGBIS->pAuxInfo->nRowCount));
	
	PRINTFUNCTIONINFO_END(GBMMISetCandRowCount);
}
SAMPLECODE_END(GBMMISetCandRowCount)


SAMPLECODE_BEGIN(GBMMIGetCandRowCount)
static void UT_GBMMIGetCandRowCount(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	GBINT nCandRowCount = 0;
	PRINTFUNCTIONINFO_BEGIN(GBMMIGetCandRowCount);
	retVal = GBMMIGetCandRowCount(pGBIS, GBCS_INPUT, &nCandRowCount);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIGetCandRowCount : GBCS_INPUT cand row count=%d\r\n", nCandRowCount));
	PRINTFUNCTIONINFO_END(GBMMIGetCandRowCount);
}
SAMPLECODE_END(GBMMIGetCandRowCount)


SAMPLECODE_BEGIN(GBMMIRegisterInterpunctionKeyEx)
static void UT_GBMMIRegisterInterpunctionKeyEx(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	PRINTFUNCTIONINFO_BEGIN(GBMMIRegisterInterpunctionKeyEx);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	retVal = GBMMIHandleKeyEvent(pGBIS, GBKEY_0, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIHandleKeyEvent key=GBKEY_0, ret = %d\r\n", retVal));
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("cand num = %d\r\n", pGBIS->outputInfo.nCandNum));
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIRegisterInterpunctionKeyEx GBKEY_0, %s\r\n", "~!@#$%^&"));
	retVal = GBMMIRegisterInterpunctionKeyEx(pGBIS, GBKEY_0, L"~!@#$%^&", 0, GBCL_ROW_MULTITAP, 1, 8, GBIKO_Input_Status_Confirm_Candidate);
	retVal = GBMMIHandleKeyEvent(pGBIS, GBKEY_0, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIHandleKeyEvent key=GBKEY_0, ret = %d\r\n", retVal));
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("cand num = %d\r\n", pGBIS->outputInfo.nCandNum));
	PRINTFUNCTIONINFO_END(GBMMIRegisterInterpunctionKeyEx);
}
SAMPLECODE_END(GBMMIRegisterInterpunctionKeyEx)


SAMPLECODE_BEGIN(GBMMIRegisterInterpunctionKey)
static void UT_GBMMIRegisterInterpunctionKey(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	PRINTFUNCTIONINFO_BEGIN(GBMMIRegisterInterpunctionKey);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	retVal = GBMMIHandleKeyEvent(pGBIS, GBKEY_0, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIHandleKeyEvent key=GBKEY_0, ret = %d\r\n", retVal));
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("cand num = %d\r\n", pGBIS->outputInfo.nCandNum));
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIRegisterInterpunctionKey GBKEY_0, %s\r\n", "~!@#$%^"));
	retVal = GBMMIRegisterInterpunctionKey(pGBIS, GBKEY_0, L"~!@#$%^", 8);
	PRINTLOOKUPINFOMATION(retVal);
	GBMMIReset(pGBIS);
	retVal = GBMMIHandleKeyEvent(pGBIS, GBKEY_0, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIHandleKeyEvent key=GBKEY_0, ret = %d\r\n", retVal));
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("cand num = %d\r\n", pGBIS->outputInfo.nCandNum));
	PRINTFUNCTIONINFO_END(GBMMIRegisterInterpunctionKey);
}
SAMPLECODE_END(GBMMIRegisterInterpunctionKey)


SAMPLECODE_BEGIN(GBMMIUnregisterInterpunctionKey)
static void UT_GBMMIUnregisterInterpunctionKey(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	PRINTFUNCTIONINFO_BEGIN(GBMMIUnregisterInterpunctionKey);
	SET_INPUT_MODE(pGBIS, GBL_Chinese, 0, GBIM_Pinyin);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIRegisterInterpunctionKeyEx GBKEY_0, %s\r\n", "~!@#$%^&"));
	GBMMIRegisterInterpunctionKeyEx(pGBIS, GBKEY_0, L"~!@#$%^&", 0, GBCL_ROW_MULTITAP, 1, 8, GBIKO_Input_Status_Confirm_Candidate);
	retVal = GBMMIHandleKeyEvent(pGBIS, GBKEY_0, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIHandleKeyEvent key=GBKEY_0, ret = %d\r\n", retVal));
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("cand num = %d\r\n", pGBIS->outputInfo.nCandNum));
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIUnregisterInterpunctionKey GBKEY_0\r\n"));
	retVal = GBMMIUnregisterInterpunctionKey(pGBIS, GBKEY_0);
	PRINTLOOKUPINFOMATION(retVal);
	GBMMIReset(pGBIS);
	retVal = GBMMIHandleKeyEvent(pGBIS, GBKEY_0, 0);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIHandleKeyEvent key=GBKEY_0, ret = %d\r\n", retVal));
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("cand num = %d\r\n", pGBIS->outputInfo.nCandNum));
	PRINTFUNCTIONINFO_END(GBMMIUnregisterInterpunctionKey);
}
SAMPLECODE_END(GBMMIUnregisterInterpunctionKey)


SAMPLECODE_BEGIN(GBMMISetAlphabeticUAWTips)
static void UT_GBMMISetAlphabeticUAWTips(pGBInputStruct pGBIS)
{
	int i = 0;
	GBRETURN retVal = 0;
	GBAlpUAWTip alpUAWTip = {GBL_English, L"开始自造？", L"确定添加？"};
	const GBWCHAR c_inputStr[] = L"98765432";
	PRINTFUNCTIONINFO_BEGIN(GBMMISetAlphabeticUAWTips);
	SET_INPUT_MODE(pGBIS, GBL_English, 0, GBIM_Predictive);
 	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBMMIHandleKeyEvent key = %s\r\n", c_inputStr));
 	for (i = 0; i < (int)wcslen(c_inputStr); i++)
 	{
		GBMMIHandleKeyEvent(pGBIS, c_inputStr[i], 0);
 	}
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"nCand[0]=%s\r\n", pGBIS->outputInfo.pCandidates[0]));
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBMMISetAlphabeticUAWTips ：nLang=%d, pszOKToSpell=%s, pszAddConfirm=%s\r\n"
		, alpUAWTip.nLang, alpUAWTip.pszOKToSpell, alpUAWTip.pszAddConfirm));
	retVal = GBMMISetAlphabeticUAWTips(pGBIS, &alpUAWTip, 1);
	PRINTLOOKUPINFOMATION(retVal);
	GBMMIReset(pGBIS);
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBMMIHandleKeyEvent key = %s\r\n", c_inputStr));
	for (i = 0; i < (int)wcslen(c_inputStr); i++)
	{
		GBMMIHandleKeyEvent(pGBIS, c_inputStr[i], 0);
	}
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"nCand[0]=%s\r\n", pGBIS->outputInfo.pCandidates[0]));

	PRINTFUNCTIONINFO_END(GBMMISetAlphabeticUAWTips);
}
SAMPLECODE_END(GBMMISetAlphabeticUAWTips)


SAMPLECODE_BEGIN(GBMMIGetInputModeBeforeSwitchLang)
static void UT_GBMMIGetInputModeBeforeSwitchLang(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	GBINT nInputMode;
	int i = 0;
	PRINTFUNCTIONINFO_BEGIN(GBMMIGetInputModeBeforeSwitchLang);
	retVal = GBMMIGetInputModeBeforeSwitchLang(pGBIS, &nInputMode);
	PRINTLOOKUPINFOMATION(retVal);

	SET_INPUT_MODE(pGBIS, GBL_English, 0, GBIM_Predictive);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMISetSwitchOption : GBL_English GBIM_Predictive to GBL_Chinese GBIM_Pinyin\r\n"));
	retVal = GBMMISetSwitchOption(pGBIS, GBKEY_AMB_SPECIAL_B, GBL_Chinese, 0, GBIM_Pinyin);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIHandleKeyEvent key = %c\r\n", '2'));
	GBMMIHandleKeyEvent(pGBIS, '2', 0);
	
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIHandleKeyEvent key = %s\r\n", "GBKEY_AMB_SPECIAL_B"));
	GBMMIHandleKeyEvent(pGBIS, GBKEY_AMB_SPECIAL_B, 0);
	retVal = GBMMIGetInputModeBeforeSwitchLang(pGBIS, &nInputMode);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIGetInputModeBeforeSwitchLang : inputMode=%s\r\n", GetInputModeStr(nInputMode)));
	PRINTFUNCTIONINFO_END(GBMMIGetInputModeBeforeSwitchLang);
}
SAMPLECODE_END(GBMMIGetInputModeBeforeSwitchLang)


SAMPLECODE_BEGIN(GBMMIReset)
static void UT_GBMMIReset(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	PRINTFUNCTIONINFO_BEGIN(GBMMIReset);
	retVal = GBMMIReset(pGBIS);
	PRINTLOOKUPINFOMATION(retVal);
	PRINTFUNCTIONINFO_END(GBMMIReset);
}
SAMPLECODE_END(GBMMIReset)


SAMPLECODE_BEGIN(GBInstallEngineWrapper)
static void UT_GBInstallEngineWrapper(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	PRINTFUNCTIONINFO_BEGIN(GBInstallEngineWrapper);
	retVal = GBInstallEngineWrapper(pGBIS, NULL, NULL);
	PRINTLOOKUPINFOMATION(retVal);
	PRINTFUNCTIONINFO_END(GBInstallEngineWrapper);
}
SAMPLECODE_END(GBInstallEngineWrapper)


SAMPLECODE_BEGIN(GBMMISetDefaultCandListType)
static void UT_GBMMISetDefaultCandListType(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	PRINTFUNCTIONINFO_BEGIN(GBMMISetDefaultCandListType);
	retVal = GBMMISetDefaultCandListType(pGBIS, GBCL_ROW_KEYBD);
	PRINTLOOKUPINFOMATION(retVal);
	PRINTFUNCTIONINFO_END(GBMMISetDefaultCandListType);
}
SAMPLECODE_END(GBMMISetDefaultCandListType)


SAMPLECODE_BEGIN(GBMMISetSwitchOption)
static void UT_GBMMISetSwitchOption(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	int i = 0;
	PRINTFUNCTIONINFO_BEGIN(GBMMISetSwitchOption);
	SET_INPUT_MODE(pGBIS, GBL_English, 0, GBIM_Predictive);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMISetSwitchOption : GBL_English GBIM_Predictive to GBL_Chinese GBIM_Pinyin\r\n"));
	retVal = GBMMISetSwitchOption(pGBIS, GBKEY_AMB_SPECIAL_B, GBL_Chinese, 0, GBIM_Pinyin);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIHandleKeyEvent key = %c\r\n", '2'));
	GBMMIHandleKeyEvent(pGBIS, '2', 0);
	for (i = 0; i < pGBIS->outputInfo.nCandNum; i++)
	{
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"%d %s ", i, pGBIS->outputInfo.pCandidates[i]));
	}
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"\r\n"));
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBMMIHandleKeyEvent key = %s\r\n", "GBKEY_AMB_SPECIAL_B"));
	GBMMIHandleKeyEvent(pGBIS, GBKEY_AMB_SPECIAL_B, 0);
	for (i = 0; i < pGBIS->outputInfo.nCandNum; i++)
	{
		PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"%d %s ", i, pGBIS->outputInfo.pCandidates[i]));
	}
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"\r\n"));

	PRINTFUNCTIONINFO_END(GBMMISetSwitchOption);
}
SAMPLECODE_END(GBMMISetSwitchOption)


SAMPLECODE_BEGIN(GBMMISetSpecialKeyMapping)
static void UT_GBMMISetSpecialKeyMapping(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	PRINTFUNCTIONINFO_BEGIN(GBMMISetSpecialKeyMapping);
	//GBMMISetSpecialKeyMapping, 在泰语等*#键上有字母的时候使用.
	SET_INPUT_MODE(pGBIS, GBL_English, 0, GBIM_Predictive);
// 	GBSetEngineOption(pGBIS, GB_ENGINE_FUNCTION, GBFO_Chn_Switch_Alp, 1);
// 	//GBMMISetSwitchOption(pGBIS, GBKEY_AMB_SPECIAL_B, GBL_Chinese, 0, GBIM_Pinyin);
// 	GBMMIHandleKeyEvent(pGBIS, '2', 0);
// 	GBMMIHandleKeyEvent(pGBIS, '3', 0);
// 	GBMMIHandleKeyEvent(pGBIS, GBKEY_AMB_SPECIAL_B, 0);
	retVal = GBMMISetSpecialKeyMapping(pGBIS, '*', '#', 0, 0);
	PRINTLOOKUPINFOMATION(retVal);
// 	SET_INPUT_MODE(pGBIS, GBL_English, 0, GBIM_Predictive);
// 	GBMMIHandleKeyEvent(pGBIS, '2', 0);
// 	GBMMIHandleKeyEvent(pGBIS, '3', 0);
// 	GBMMIHandleKeyEvent(pGBIS, GBKEY_AMB_SPECIAL_B, 0);
	PRINTFUNCTIONINFO_END(GBMMISetSpecialKeyMapping);
}
SAMPLECODE_END(GBMMISetSpecialKeyMapping)


SAMPLECODE_BEGIN(GBMMISetQwertyMapArray)
static void UT_GBMMISetQwertyMapArray(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	GBLPCWCHAR g_pcQwertyMapArray[] = {
		L"qwertyuiopasdfghjklzxcvbnm,."
		,L"+()123*-_@;:&456#/\\!?$7890'\""
	};
	PRINTFUNCTIONINFO_BEGIN(GBMMISetQwertyMapArray);
	PT_PrintLogInfoW(e_GBLOG_UNITTEST, (L"GBMMISetQwertyMapArray :\r\n[1]     %s\r\n[2]     %s\r\n", g_pcQwertyMapArray[0], g_pcQwertyMapArray[1]));
	retVal = GBMMISetQwertyMapArray(pGBIS, g_pcQwertyMapArray, 2);
	PRINTLOOKUPINFOMATION(retVal);
	PRINTFUNCTIONINFO_END(GBMMISetQwertyMapArray);
}
SAMPLECODE_END(GBMMISetQwertyMapArray)


//#Version 国笔版本号相关函数

SAMPLECODE_BEGIN(GBGetOEMID)
static void UT_GBGetOEMID(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	GBI32 OEMid = 0;
	PRINTFUNCTIONINFO_BEGIN(GBGetOEMID);
	retVal = GBGetOEMID(pGBIS, &OEMid);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetOEMID : OEMid = %d\r\n", OEMid));
	PRINTFUNCTIONINFO_END(GBGetOEMID);
}
SAMPLECODE_END(GBGetOEMID)


SAMPLECODE_BEGIN(GBGetBuildID)
static void UT_GBGetBuildID(pGBInputStruct pGBIS)
{
	GBRETURN retVal = 0;
	GBI32 buildID = 0;
	PRINTFUNCTIONINFO_BEGIN(GBGetBuildID);
	retVal = GBGetBuildID(pGBIS, &buildID);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBGetBuildID : buildID = %d\r\n", buildID));
	PRINTFUNCTIONINFO_END(GBGetBuildID);
}
SAMPLECODE_END(GBGetBuildID)


SAMPLECODE_BEGIN(GBGetEngineVersion)
static void UT_GBGetEngineVersion(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	GBVersion version = {0};
	PRINTFUNCTIONINFO_BEGIN(GBGetEngineVersion);
	retVal = GBGetEngineVersion(pGBIS, &version);
	PRINTLOOKUPINFOMATION(retVal);
	PT_PrintLogInfo(e_GBLOG_UNITTEST, ("GBVersion : v1=%d, v2=%d, v3=%d, v4=%d \r\n", version.v1, version.v2, version.v3, version.v4));
	PRINTFUNCTIONINFO_END(GBGetEngineVersion);
}
SAMPLECODE_END(GBGetEngineVersion)

//#Timer	MultiTap定时器

SAMPLECODE_BEGIN(GBMMIAttachTimerFunction)
static void UT_GBMMIAttachTimerFunction(pGBInputStruct pGBIS)
{
	GBRETURN retVal;
	PRINTFUNCTIONINFO_BEGIN(GBMMIAttachTimerFunction);
	retVal = GBMMIAttachTimerFunction(pGBIS, onSetTimer, onKillTimer, NULL);
	PRINTLOOKUPINFOMATION(retVal);
	PRINTFUNCTIONINFO_END(GBMMIAttachTimerFunction);
}
SAMPLECODE_END(GBMMIAttachTimerFunction)

//////////////////////////////////////////////////////////////////////////



	typedef void (* pfUnitTest)(pGBInputStruct pGBIS);
// 单元测试函数数组
const pfUnitTest c_fpArray[] = {
	//#Initialization 引擎初始化
 	UT_GBInputStructGetPrivateBufferUsedSize
 	,UT_GBInitialize
 	,UT_GBIsInited
 	,UT_GBTerminate
 	,UT_GBReset
 	,UT_GBSetCurLanguage
 	,UT_GBSetInputMode
	,UT_GBMMISetInputMode
	//#Configuration	API引擎配置
	,UT_GBSetCandidateMaxCount
	,UT_GBGetCandidateMaxCount
	,UT_GBSetLanguageSymbols
	,UT_GBSetPageOption
	,UT_GBGetPageOption
	,UT_GBSetMaxTotalPages
	,UT_GBGetMaxTotalPages
	,UT_GBSetCandidateMaxWordLength
	,UT_GBSetInputString
	,UT_GBHelperAddInputChar
	,UT_GBHelperAddInputString
	//#Chinese 中文专门的函数
	,UT_GBGetAllSyllableCount
	,UT_GBGetSyllable
	,UT_GBSelectSyllable
	,UT_GBSelectSyllableEx
	,UT_GBGetSyllables
	,UT_GBUpdateSyllable
	,UT_GBGeSyllablePageCount
	,UT_GBGetCurrentSyllablePageIndex
	,UT_GBSetFuzzy
	,UT_GBWord2CodesByInputmod
	,UT_GBTranslateInputStringToSyllable 
	,UT_GBChnGetAfterChar 
	,UT_GBSetEngineOption
	,UT_GBGetEngineOption
	,UT_GBGetPagedSyllable
	,UT_GBChnGetComponents
	,UT_GBSetAssocWord
	,UT_GBGetAssocWord
	,UT_GBSetSyllableTone
	//#Alphabetic Alphabetic专门的函数
	,UT_GBGetDesireOutput
	,UT_GBConvertChar
	,UT_GBConvertString
	,UT_GBConvertStringToNumPadKeySequence 
	,UT_GBTransform
	,UT_GBTransformReverse
	,UT_GBSetShiftCap
	,UT_GBAlpGetValidInputStr
	,UT_GBALPSetAbbreviateWordTreeEnable
	//#Candidate 获取候选的API
	,UT_GBHaveNextPage
	,UT_GBHavePrevPage
	,UT_GBNextPageCandidate
	,UT_GBNextPageCandidateEx 
	,UT_GBPrevPageCandidate
	,UT_GBCurPageCandidateEx 
	,UT_GBCurPageCandidate 
	,UT_GBSelectCandidate
	,UT_GBSelectCandidateEx
	,UT_GBCancelSelectCandidate
	,UT_GBSetCandBuffer
	,UT_GBGetCandBufferLen
	,UT_GBGetCandidate
	,UT_GBGetCandidateEx 
	,UT_GBGetCandidatesCount
	,UT_GBGetCandidatePageCount
	,UT_GBGetCurrentCandidatePageIndex
	,UT_GBUpscreenChar
	,UT_GBTransFormat
	,UT_GBUpscreenString
	,UT_GBAlpGetEmbeddedInterpunctionKey
	,UT_GBChnControlChar
	,UT_GBInputResetNoHook
	,UT_GBSetCandType
	,UT_GBUpdateOutputInfo
	,UT_GBGetFullInputString
	//#MDB 细胞数据库（MDB）
	,UT_GBMDBInit
	,UT_GBMDBAttach 
	,UT_GBMDBAttachFile 
	,UT_GBMDBDetach
	,UT_GBMDBCheckPhrase 
	,UT_GBMDBAddPhrase 
	//#UDB 用户自造词函数
	,UT_GBAddUsedWord
	,UT_GBUDBAttach 
	,UT_GBChnUDBAttach 
	,UT_GBChnUDBDetach
	,UT_GBChnUDBDataReset
	,UT_GBChnUDBSetUpdateParam 
	,UT_GBUDBSetUpdateParam 
	,UT_GBUDBGetModifiedCount 
	,UT_GBUDBDataReset
	,UT_GBUDBDetach
	,UT_GBUDBAddPhrase 
	,UT_GBUDBDeletePhrase
	,UT_GBUDBGetNextPhrase
	//#Auxiliary	辅助API
	,UT_GBIsInDatabase
	,UT_GBGetLastError
	,UT_GBSetLastError
	,UT_GBSetLastErrorEx 
	,UT_GBAttachLogRecorder
	,UT_GBGetDataLanguage
	//#GBMMI	GBMMI函数
	,UT_GBMMIHandleKeyEvent
	,UT_GBMMISetCandRowCount
	,UT_GBMMIGetCandRowCount
	,UT_GBMMIRegisterInterpunctionKeyEx 
	,UT_GBMMIRegisterInterpunctionKey 
	,UT_GBMMIUnregisterInterpunctionKey
	,UT_GBMMISetAlphabeticUAWTips 
	,UT_GBMMIGetInputModeBeforeSwitchLang
	,UT_GBMMIReset
	,UT_GBInstallEngineWrapper 
	,UT_GBMMISetDefaultCandListType
	,UT_GBMMISetSwitchOption 
	,UT_GBMMISetSpecialKeyMapping 
	,UT_GBMMISetQwertyMapArray
	//#Version 国笔版本号相关函数
	,UT_GBGetOEMID
	,UT_GBGetBuildID
	,UT_GBGetEngineVersion
	//#Timer	MultiTap定时器
	,UT_GBMMIAttachTimerFunction 

};


int _tmain(int argc, _TCHAR* argv[])
{
	pGBInputStruct pGBIS = GetEngineInputStruct();
	int ch;
#if GBIME_LOG_FILE > 0
	OpenLogFile("log.txt");
#endif

	// 加载输入法引擎
	if (GBIM_LoadEngine() != GBOK)
	{
		PT_PrintModuleLogInfo(e_GBLOG_UNITTEST, ("输入法引擎初始化失败 \n"));
		return -1;
	}
	PT_PrintModuleLogInfo(e_GBLOG_UNITTEST, ("输入法引擎初始化成功 \n"));

	// 引擎是否初始化
	if(UT_GBIsInited(pGBIS))
	{
		int index;
#if 1
		UT_GBConvertString(pGBIS);
#else
		// 单元测试
		for (index = 0; index < ARRAY_DIM(c_fpArray); index++)
		{
			c_fpArray[index](pGBIS);
		}
#endif
	}
#if GBIME_LOG_FILE > 0
	CloseLogFile();
#endif

	ch = _getch();
	GBIM_UnLoadEngine();


	return 0;
}

